Constructor
new Deferred(executableopt, onResolveopt, onRejectopt, onCancelopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
executable |
function |
<optional> |
() => {} | The function to be executed by the |
onResolve |
function |
<optional> |
Optional function to execute once the promise |
|
onReject |
function |
<optional> |
Optional function to execute once the promise |
|
onCancel |
function |
<optional> |
Optional function to execute if the user cancels |
Extends
Members
(readonly) canceled
Gets the canceled state of the promise.
(readonly) pending
Gets the pending state of the promise.
(readonly) rejected
Gets the rejected state of the promise.
(readonly) resolved
Gets the resolved state of the promise.
Methods
(static) all(iterable, onResolveopt, onRejectopt, onCancelopt)
Return a new Deferred promise that will resolve or reject once all promises
in the input array have been resolved or one promise is canceled or rejected.
Promises in the array that are Deferred promises will be manually resolved,
rejected or canceled when calling resolve, reject or cancel on the return promise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterable |
Array.<any> | An iterable such as an array. |
|
onResolve |
function |
<optional> |
Optional function to execute once the promise |
onReject |
function |
<optional> |
Optional function to execute once the promise |
onCancel |
function |
<optional> |
Optional function to execute if the user cancels |
Returns:
Deferred
(static) cancel(valueopt) → {Deferred}
Return a canceled deferred promise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any |
<optional> |
Value to cancel the promise with. |
Returns:
- Type
- Deferred
cancel(valueopt) → {any}
Force the promise to resolve and set the canceled state to true.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any |
<optional> |
Value to pass to the canceller. |
Returns:
- The return value of the canceller function.
- Type
- any
execute(…args)
Run the promise function to try to resolve the promise. Promise must be
pending.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
any |
<repeatable> |
Optional arguments to pass after resolve and reject. |
reject(valueopt) → {any}
Force the promise to reject.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any |
<optional> |
Value to pass to the rejecter. |
Returns:
- The return value of the rejecter function.
- Type
- any
resolve(valueopt) → {any}
Force the promise to resolve.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any |
<optional> |
Value to pass to the resolver. |
Returns:
- The return value of the resolver function.
- Type
- any