A.CancellablePromise Class
Cancellable promise.
Constructor
A.CancellablePromise
-
fn
-
opt_errorCallback
Parameters:
-
fn
FunctionA function where to insert the logic that resolves this promise. Receives
fulfill
andreject
functions as parameters. This function is called synchronously. -
opt_errorCallback
FunctionOptional error callback to be fired whenever a cancellable promise is cancelled.
Index
Methods
Properties
Methods
_cancelChildPromises
-
childPromise
-
opt_message
Cancels children Promises. If the Promise has not already been resolved, reject it with a cancel error. If there are no other children in the list of callback entries, propagate the cancellation by canceling this Promise as well.
Parameters:
-
childPromise
CancellablePromiseThe Promise to cancel.
-
opt_message
StringAn optional debugging message for describing the cancellation reason.
cancel
-
opt_message
Cancels the Promise by rejecting it with a A.CancellablePromise.Error
. No
action is performed if the Promise is already resolved.
Parameters:
-
opt_message
StringAn optional debugging message for describing the cancellation reason.
thenAways
-
callback
Adds a callback that will be invoked whether the Promise is fulfilled or
rejected. The callback receives no argument, and a new child Promise is
created. This is useful for ensuring that cleanup takes place after certain
asynchronous operations. Callbacks added with thenAlways
will be executed
in the same order with other calls to then
, thenAlways
.
Parameters:
-
callback
FunctionA function that will be invoked when the Promise is resolved.
Returns:
A new Promise that will receive the result of the callback.
thenCatch
-
callback
Adds a callback that will be invoked only if the Promise is rejected. This is
equivalent to then(null, onRejected)
.
Parameters:
-
callback
FunctionA function that will be invoked with the rejection reason if the Promise is rejected.
Returns:
A new Promise that will receive the result of the callback.
Properties
_childPromises
Array
protected
Holds the list of children promises.
_errorCallback
Function
protected
Holds the Optional error callback to be fired whenever a cancellable promise is cancelled.