mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-30 18:43:21 +08:00
Merge pull request #1865 from johnnyreilly/master
jQuery: Promises promises
This commit is contained in:
260
jquery/jquery.d.ts
vendored
260
jquery/jquery.d.ts
vendored
@@ -253,79 +253,259 @@ interface JQueryCallback {
|
||||
remove(callbacks: Function[]): JQueryCallback;
|
||||
}
|
||||
|
||||
/*
|
||||
Allows jQuery Promises to interop with non-jQuery promises
|
||||
*/
|
||||
/**
|
||||
* Allows jQuery Promises to interop with non-jQuery promises
|
||||
*/
|
||||
interface JQueryGenericPromise<T> {
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => U): JQueryGenericPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (reason: any) => U): JQueryGenericPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => JQueryGenericPromise<U>): JQueryGenericPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (reason: any) => JQueryGenericPromise<U>): JQueryGenericPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => U, failFilter?: (reason: any) => U): JQueryGenericPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => JQueryGenericPromise<U>, failFilter?: (reason: any) => U): JQueryGenericPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => U, failFilter?: (reason: any) => JQueryGenericPromise<U>): JQueryGenericPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => JQueryGenericPromise<U>, failFilter?: (reason: any) => JQueryGenericPromise<U>): JQueryGenericPromise<U>;
|
||||
}
|
||||
|
||||
/*
|
||||
Interface for the JQuery promise, part of callbacks
|
||||
*/
|
||||
/**
|
||||
* Interface for the JQuery promise, part of callbacks
|
||||
*/
|
||||
interface JQueryPromise<T> {
|
||||
// Generic versions of callbacks
|
||||
always(...alwaysCallbacks: T[]): JQueryPromise<T>;
|
||||
done(...doneCallbacks: T[]): JQueryPromise<T>;
|
||||
fail(...failCallbacks: T[]): JQueryPromise<T>;
|
||||
progress(...progressCallbacks: T[]): JQueryPromise<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is either resolved or rejected.
|
||||
*
|
||||
* @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected.
|
||||
* @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected.
|
||||
*/
|
||||
always(alwaysCallbacks1: T, ...alwaysCallbacks2: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved.
|
||||
*
|
||||
* @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved.
|
||||
* @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved.
|
||||
*/
|
||||
done(doneCallbacks1: T, ...doneCallbacks2: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is rejected.
|
||||
*
|
||||
* @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected.
|
||||
* @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected.
|
||||
*/
|
||||
fail(failCallbacks1: T, ...failCallbacks2: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object generates progress notifications.
|
||||
*
|
||||
* @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications.
|
||||
*/
|
||||
progress(...progressCallbacks: T[]): JQueryDeferred<T>;
|
||||
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is either resolved or rejected.
|
||||
*
|
||||
* @param alwaysCallbacks A function, or array of functions, that is called when the Deferred is resolved or rejected.
|
||||
*/
|
||||
always(...alwaysCallbacks: any[]): JQueryPromise<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved.
|
||||
*
|
||||
* @param doneCallbacks A function, or array of functions, that are called when the Deferred is resolved.
|
||||
*/
|
||||
done(...doneCallbacks: any[]): JQueryPromise<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is rejected.
|
||||
*
|
||||
* @param failCallbacks A function, or array of functions, that are called when the Deferred is rejected.
|
||||
*/
|
||||
fail(...failCallbacks: any[]): JQueryPromise<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object generates progress notifications.
|
||||
*
|
||||
* @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications.
|
||||
*/
|
||||
progress(...progressCallbacks: any[]): JQueryPromise<T>;
|
||||
|
||||
// Deprecated - given no typings
|
||||
pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise<any>;
|
||||
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => U, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => JQueryGenericPromise<U>, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => U, failFilter?: (...reasons: any[]) => JQueryGenericPromise<U>, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (value: T) => JQueryGenericPromise<U>, failFilter?: (...reasons: any[]) => JQueryGenericPromise<U>, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
|
||||
// Because JQuery Promises Suck
|
||||
then<U>(onFulfill: (...values: any[]) => U, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
then<U>(onFulfill: (...values: any[]) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
then<U>(onFulfill: (...values: any[]) => U, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
then<U>(onFulfill: (...values: any[]) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (...values: any[]) => U, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (...values: any[]) => JQueryGenericPromise<U>, failFilter?: (...reasons: any[]) => U, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (...values: any[]) => U, failFilter?: (...reasons: any[]) => JQueryGenericPromise<U>, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
|
||||
*
|
||||
* @param doneFilter A function that is called when the Deferred is resolved.
|
||||
* @param failFilter An optional function that is called when the Deferred is rejected.
|
||||
* @param progressFilter An optional function that is called when progress notifications are sent to the Deferred.
|
||||
*/
|
||||
then<U>(doneFilter: (...values: any[]) => JQueryGenericPromise<U>, failFilter?: (...reasons: any[]) => JQueryGenericPromise<U>, progressFilter?: (...progression: any[]) => any): JQueryPromise<U>;
|
||||
}
|
||||
|
||||
/*
|
||||
Interface for the JQuery deferred, part of callbacks
|
||||
*/
|
||||
/**
|
||||
* Interface for the JQuery deferred, part of callbacks
|
||||
*/
|
||||
interface JQueryDeferred<T> extends JQueryPromise<T> {
|
||||
// Generic versions of callbacks
|
||||
always(...alwaysCallbacks: T[]): JQueryDeferred<T>;
|
||||
done(...doneCallbacks: T[]): JQueryDeferred<T>;
|
||||
fail(...failCallbacks: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is either resolved or rejected.
|
||||
*
|
||||
* @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected.
|
||||
* @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected.
|
||||
*/
|
||||
always(alwaysCallbacks1: T, ...alwaysCallbacks2: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is resolved.
|
||||
*
|
||||
* @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved.
|
||||
* @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved.
|
||||
*/
|
||||
done(doneCallbacks1: T, ...doneCallbacks2: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object is rejected.
|
||||
*
|
||||
* @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected.
|
||||
* @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected.
|
||||
*/
|
||||
fail(failCallbacks1: T, ...failCallbacks2: T[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Add handlers to be called when the Deferred object generates progress notifications.
|
||||
*
|
||||
* @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications.
|
||||
*/
|
||||
progress(...progressCallbacks: T[]): JQueryDeferred<T>;
|
||||
|
||||
always(...alwaysCallbacks: any[]): JQueryDeferred<T>;
|
||||
done(...doneCallbacks: any[]): JQueryDeferred<T>;
|
||||
fail(...failCallbacks: any[]): JQueryDeferred<T>;
|
||||
progress(...progressCallbacks: any[]): JQueryDeferred<T>;
|
||||
|
||||
/**
|
||||
* Call the progressCallbacks on a Deferred object with the given args.
|
||||
*
|
||||
* @param args Optional arguments that are passed to the progressCallbacks.
|
||||
*/
|
||||
notify(...args: any[]): JQueryDeferred<T>;
|
||||
|
||||
/**
|
||||
* Call the progressCallbacks on a Deferred object with the given context and args.
|
||||
*
|
||||
* @param context Context passed to the progressCallbacks as the this object.
|
||||
* @param args Optional arguments that are passed to the progressCallbacks.
|
||||
*/
|
||||
notifyWith(context: any, ...args: any[]): JQueryDeferred<T>;
|
||||
|
||||
/**
|
||||
* Reject a Deferred object and call any failCallbacks with the given args.
|
||||
*
|
||||
* @param args Optional arguments that are passed to the failCallbacks.
|
||||
*/
|
||||
reject(...args: any[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Reject a Deferred object and call any failCallbacks with the given context and args.
|
||||
*
|
||||
* @param context Context passed to the failCallbacks as the this object.
|
||||
* @param args An optional array of arguments that are passed to the failCallbacks.
|
||||
*/
|
||||
rejectWith(context: any, ...args: any[]): JQueryDeferred<T>;
|
||||
|
||||
resolve(val: T): JQueryDeferred<T>;
|
||||
/**
|
||||
* Resolve a Deferred object and call any doneCallbacks with the given args.
|
||||
*
|
||||
* @param args Optional arguments that are passed to the doneCallbacks.
|
||||
*/
|
||||
resolve(...args: any[]): JQueryDeferred<T>;
|
||||
|
||||
/**
|
||||
* Resolve a Deferred object and call any doneCallbacks with the given context and args.
|
||||
*
|
||||
* @param context Context passed to the doneCallbacks as the this object.
|
||||
* @param args An optional array of arguments that are passed to the doneCallbacks.
|
||||
*/
|
||||
resolveWith(context: any, ...args: any[]): JQueryDeferred<T>;
|
||||
/**
|
||||
* Determine the current state of a Deferred object.
|
||||
*/
|
||||
state(): string;
|
||||
|
||||
/**
|
||||
* Return a Deferred's Promise object.
|
||||
*
|
||||
* @param target Object onto which the promise methods have to be attached
|
||||
*/
|
||||
promise(target?: any): JQueryPromise<T>;
|
||||
}
|
||||
|
||||
/*
|
||||
Interface of the JQuery extension of the W3C event object
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface of the JQuery extension of the W3C event object
|
||||
*/
|
||||
interface BaseJQueryEventObject extends Event {
|
||||
data: any;
|
||||
delegateTarget: Element;
|
||||
|
||||
Reference in New Issue
Block a user