| @@ -1,5 +1,4 | |||
|
|
1 |
import { ICancellable, Constructor, IDestroyable, |
|
|
|
2 | import { Cancellation } from "./Cancellation"; | |
|
|
1 | import { ICancellable, Constructor, IDestroyable, ICancellation } from "./interfaces"; | |
|
|
3 | 2 | |
|
|
4 | 3 | let _nextOid = 0; |
|
|
5 | 4 | const _oid = typeof Symbol === "function" ? |
| @@ -18,6 +17,23 export function oid(instance: any): stri | |||
|
|
18 | 17 | return (instance[_oid] = "oid_" + (++_nextOid)); |
|
|
19 | 18 | } |
|
|
20 | 19 | |
|
|
20 | const cancellationNone: ICancellation = { | |
|
|
21 | isSupported(): boolean { | |
|
|
22 | return false; | |
|
|
23 | }, | |
|
|
24 | ||
|
|
25 | throwIfRequested(): void { | |
|
|
26 | }, | |
|
|
27 | ||
|
|
28 | isRequested(): boolean { | |
|
|
29 | return false; | |
|
|
30 | }, | |
|
|
31 | ||
|
|
32 | register(_cb: (e: any) => void): IDestroyable { | |
|
|
33 | return destroyed; | |
|
|
34 | } | |
|
|
35 | }; | |
|
|
36 | ||
|
|
21 | 37 | export function keys<T>(arg: T): (Extract<keyof T, string>)[] { |
|
|
22 | 38 | return isObject(arg) && arg ? Object.keys(arg) as (Extract<keyof T, string>)[] : []; |
|
|
23 | 39 | } |
| @@ -272,7 +288,7 export function delegate(target: any, _m | |||
|
|
272 | 288 | }; |
|
|
273 | 289 | } |
|
|
274 | 290 | |
|
|
275 |
export function delay(timeMs: number, ct = |
|
|
|
291 | export function delay(timeMs: number, ct = cancellationNone) { | |
|
|
276 | 292 | ct.throwIfRequested(); |
|
|
277 | 293 | return new Promise((resolve, reject) => { |
|
|
278 | 294 | const h = ct.register(e => { |
General Comments 0
You need to be logged in to leave comments.
Login now
