forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery-ajax-chain.d.ts
97 lines (82 loc) · 3.23 KB
/
jquery-ajax-chain.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Type definitions for jquery-ajax-chain v 1.0.4
// Project: https://github.com/humana-fragilitas/jQuery-Ajax-Chain/
// Definitions by: Andrea Blasio <https://github.com/humana-fragilitas>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
declare module ajaxChain {
/**
* Static members of JQueryAjaxChain
*/
interface JQueryAjaxChainStatic {
new (): JQueryAjaxChain
}
/**
* Instance members of JQueryAjaxChain
*/
interface JQueryAjaxChain extends JQueryPromise<any> {
/**
* Enqueues one or more configuration objects for later processing.
*/
enqueue(confObj: AjaxChainConfiguration | AjaxChainConfiguration[]): JQueryAjaxChain;
/**
* Sequentially and synchronously dequeues the configuration objects enqueued via enqueue() method
* in the order they were added, triggering the related Ajax calls.
*/
dequeue(): JQueryAjaxChain;
/**
* Clears the currently queued configuration objects.
*/
clearQueue(): JQueryAjaxChain;
}
/**
* A set of key/value pairs that configure the AjaxChain request; 'ajaxSettings' is mandatory.
*/
interface AjaxChainConfiguration {
/**
* jQuery $.ajax method settings (required).
*/
ajaxSettings: JQueryAjaxSettings;
/**
* Configuration object label (optional).
*/
label?: String;
/**
* Returning a truthy value (Object) allows to arbitrarily overwrite the next queued Ajax call
* 'data' property value specified in the original jQuery $.ajax method configuration
* object ('ajaxSettings') (optional).
*/
transform?: (response: any) => String | Object | Object[];
/**
* Returning a truthy value (String) allows to append a string to the next queued
* Ajax call 'url' property value specified in original jQuery $.ajax method configuration
* object ('ajaxSettings') (optional).
*/
appendToUrl?: (response: any) => String;
/**
* Returning a truthy value determines any registered fail callback(s) to be called immediately,
* passing the former as an argument to the latter; the queue is then rejected (optional).
*/
hasErrors?: (response: any) => any;
/**
* Returning a truthy value allows to prevent the related Ajax call from being executed,
* passing the former as a parameter to any registered handler(s); useful to create
* caching mechanisms (optional).
*/
hasCache?: (response: any) => any;
/**
* Returning a truthy value prevents the queue from further progressing to the succeeding
* Ajax calls; the queue is then resolved (optional).
*/
hasHaltingCapabilities?: (response: any) => Boolean;
/**
* Returning a truthy value prevents the queue from being halted in case of Ajax error (optional).
*/
isSkippable?: (response: any) => Boolean;
}
}
interface JQueryStatic {
/**
* JQueryAjaxChain constructor
*/
AjaxChain: ajaxChain.JQueryAjaxChainStatic;
}