Promise.d.ts
68 lines
| 1.8 KiB
| video/mp2t
|
TypeScriptLexer
cin
|
r2 | declare namespace DojoPromise { | ||
interface Thenable<T> extends PromiseLike<T> { | ||||
/** | ||||
* Add new callbacks to the promise. | ||||
*/ | ||||
then<U1, U2>(callback?: PromiseCallback<T, U1>, errback?: PromiseErrback<U2>, progback?: PromiseProgback): Thenable<U1 | U2>; | ||||
} | ||||
type PromiseCallback<T, U> = ((value: T) => U | PromiseLike<U>) | undefined | null; | ||||
type PromiseErrback<U> = PromiseCallback<any, U>; | ||||
type PromiseProgback = (progress: any) => void; | ||||
interface DojoPromise<T> extends Thenable<T> { | ||||
/** | ||||
* Inform the deferred it may cancel its asynchronous operation. | ||||
*/ | ||||
cancel(reason?: any, strict?: boolean): any; | ||||
/** | ||||
* Checks whether the promise has been resolved. | ||||
*/ | ||||
isResolved(): boolean; | ||||
/** | ||||
* Checks whether the promise has been rejected. | ||||
*/ | ||||
isRejected(): boolean; | ||||
/** | ||||
* Checks whether the promise has been resolved or rejected. | ||||
*/ | ||||
isFulfilled(): boolean; | ||||
/** | ||||
* Checks whether the promise has been canceled. | ||||
*/ | ||||
isCanceled(): boolean; | ||||
/** | ||||
* Add a callback to be invoked when the promise is resolved | ||||
* or rejected. | ||||
*/ | ||||
always<U>(callbackOrErrback: PromiseCallback<any, U>): DojoPromise<U>; | ||||
/** | ||||
* Add new errbacks to the promise. | ||||
*/ | ||||
otherwise<U>(errback: PromiseErrback<U>): DojoPromise<U>; | ||||
trace(): this; | ||||
traceRejected(): this; | ||||
toString(): string; | ||||
} | ||||
interface DojoPromiseConstructor { | ||||
/** | ||||
* The public interface to a deferred. | ||||
*/ | ||||
new <T>(): DojoPromise<T>; | ||||
} | ||||
} | ||||
type DojoPromise<T> = DojoPromise.DojoPromise<T>; | ||||
declare const DojoPromise: DojoPromise.DojoPromiseConstructor; | ||||
export = DojoPromise; | ||||