-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuture.d.ts
33 lines (26 loc) · 911 Bytes
/
future.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
declare module "junk-bucket/future" {
export class Future<T> {
/**
* resolved indicates the promise has been resolved. Used for correctness internally. Could be used to construct
* gates.
*/
public readonly resolved: boolean;
public promised: Promise<T>;
constructor();
public accept(value: T): void;
public reject(value: any): void;
}
/**
* Provides a future which will be resolved after ms . Caveat on all browser setTimeout/setInterval issues.
* @param ms number of milliseconds to delay
* @param value the value to be returned after the delay
*/
export function delay<T>(ms: number, value?:T): Promise<T>;
interface EventHandler {
(event: any): void
}
export interface OnceEmitter {
once(eventName: string, handler: EventHandler): any
}
export function promiseEvent(from: OnceEmitter, eventName: string): Future<any>;
}