Deferred
,
and may have an execution sequence of callback functions added to it. Each
DeferredList
instance is single use and may be fired only once.
The default behavior of a DeferredList
is to wait for a success
or error result from every Deferred
in its input list. Once
every result is available, the DeferredList
's execution sequence
is fired with a list of [success, result]
array pairs, where
success
is a boolean indicating whether result
was
the product of a callback or errback. The list's completion criteria and
result list may be modified by setting one or more of the boolean options
documented below.
Deferred
instances passed into a DeferredList
are
independent, and may have additional callbacks and errbacks added to their
execution sequences after they are passed as inputs to the list.
goog.async.Deferred | |
goog.async.DeferredList | goog.async.Deferred |
list
: !Array.<!goog.async.Deferred>
An array of deferred results to
wait for.
|
opt_fireOnOneCallback
: boolean=
Whether to stop waiting as soon as
one input completes successfully. In this case, the
DeferredList 's callback chain will be called with a two
element array, [index, result] , where index
identifies which input Deferred produced the successful
result . |
opt_fireOnOneErrback
: boolean=
Whether to stop waiting as soon as one
input reports an error. The failing result is passed to the
DeferredList 's errback sequence. |
opt_consumeErrors
: boolean=
When true, any errors fired by a
Deferred in the input list will be captured and replaced
with a succeeding null result. Any callbacks added to the
Deferred after its use in the DeferredList will
receive null instead of the error. |
opt_canceler
: Function=
A function that will be called if the
DeferredList is canceled. @see goog.async.Deferred#cancel |
opt_defaultScope
: Object=
The default scope to invoke callbacks or
errbacks in.
|
![]()
No description.
|
code » | ||||
![]()
Registers the result from an input deferred callback or errback. The result
is returned and may be passed to additional handlers in the callback chain.
Arguments:
Returns: *
The result, to be handled by the next handler in the deferred's
callback chain (if any). If consumeErrors is set, an error result is
replaced with null.
|
code » |
Registers one function as both a callback and errback.
Arguments:
Returns: !goog.async.Deferred
This Deferred.
|
code » | ||||
Register a callback function to be called with a successful result. If no
value is returned by the callback function, the result value is unchanged. If
a new value is returned, it becomes the Deferred result and will be passed to
the next callback in the execution sequence.
If the function throws an error, the error becomes the new result and will be
passed to the next errback in the execution chain.
If the function returns a Deferred, the execution sequence will be blocked
until that Deferred fires. Its result will be passed to the next callback (or
errback if it is an error result) in this Deferred's execution sequence.
Arguments:
Returns: !goog.async.Deferred
This Deferred.
|
code » | ||||
Registers a callback function and an errback function at the same position
in the execution sequence. Only one of these functions will execute,
depending on the error state during the execution sequence.
NOTE: This is not equivalent to
def.addCallback().addErrback() ! If
the callback is invoked, the errback will be skipped, and vice versa.
Arguments:
Returns: !goog.async.Deferred
This Deferred.
|
code » | ||||
Register a callback function to be called with an error result. If no value
is returned by the function, the error result is unchanged. If a new error
value is returned or thrown, that error becomes the Deferred result and will
be passed to the next errback in the execution sequence.
If the errback function handles the error by returning a non-error value,
that result will be passed to the next normal callback in the sequence.
If the function returns a Deferred, the execution sequence will be blocked
until that Deferred fires. Its result will be passed to the next callback (or
errback if it is an error result) in this Deferred's execution sequence.
Arguments:
|
code » | ||||
![]()
Asserts that an object is not a Deferred.
Arguments:
|
code » | ||||
Makes this Deferred wait for another Deferred's execution sequence to
complete before continuing.
This is equivalent to adding a callback that returns
otherDeferred ,
but doesn't prevent additional callbacks from being added to
otherDeferred .
Arguments:
Returns: !goog.async.Deferred
This Deferred.
|
code » | ||||
Creates a branch off this Deferred's execution sequence, and returns it as a
new Deferred. The branched Deferred's starting result will be shared with the
parent at the point of the branch, even if further callbacks are added to the
parent.
All branches at the same stage in the execution sequence will receive the
same starting value.
Arguments:
Returns: !goog.async.Deferred.<VALUE>
A Deferred that will be started with
the computed result from this stage in the execution sequence.
|
code » | ||||
![]()
Handle a single branch being canceled. Once all branches are canceled, this
Deferred will be canceled as well.
|
code » | ||||
![]()
Fire the execution sequence for this Deferred by passing the starting result
to the first registered callback.
Arguments:
|
code » | ||||
![]()
Cancels a Deferred that has not yet been fired, or is blocked on another
deferred operation. If this Deferred is waiting for a blocking Deferred to
fire, the blocking Deferred will also be canceled.
If this Deferred was created by calling branch() on a parent Deferred with
opt_propagateCancel set to true, the parent may also be canceled. If
opt_deepCancel is set, cancel() will be called on the parent (as well as any
other ancestors if the parent is also a branch). If one or more branches were
created with opt_propagateCancel set to true, the parent will be canceled if
cancel() is called on all of those branches.
Arguments:
|
code » | ||||
Links another Deferred to the end of this Deferred's execution sequence. The
result of this execution sequence will be passed as the starting result for
the chained Deferred, invoking either its first callback or errback.
Arguments:
Returns: !goog.async.Deferred
This Deferred.
|
code » | ||||
![]()
Verifies that the Deferred has not yet been fired.
|
code » | ||||
![]()
Called after a blocking Deferred fires. Unblocks this Deferred and resumes
its execution sequence.
Arguments:
|
code » | ||||
![]()
Fire the execution sequence for this Deferred by passing the starting error
result to the first registered errback.
Arguments:
|
code » | ||||
![]()
Exhausts the execution sequence while a result is available. The result may
be modified by callbacks or errbacks, and execution will block if the
returned result is an incomplete Deferred.
|
code » | ||||
No description.
Returns: boolean
Whether an errback exists in the remaining sequence.
|
code » | ||||
No description.
Returns: boolean
Whether the execution sequence has been started on this
Deferred by invoking
callback or errback .
|
code » | ||||
No description.
Arguments:
Returns: boolean
Whether the current result is an error that should cause
the next errback to fire. May be overridden by subclasses to handle
special error types.
|
code » | ||||
![]()
Attempt to make the error's stack trace be long in that it contains the
stack trace from the point where the deferred was created on top of the
current stack trace to give additional context.
Arguments:
|
code » | ||||
![]()
Implements for seamless integration with
.
Deferred results are mutable and may represent multiple values over
their lifetime. Calling
then on a Deferred returns a Promise
with the result of the Deferred at that point in its callback chain.
Note that if the Deferred result is never mutated, and only
then calls are made, the Deferred will behave like a Promise.
|
code » | ||||
![]()
Updates the current result based on the success or failure of the last action
in the execution sequence.
Arguments:
|
code » |
![]()
No description.
|
Code » | |
![]()
Whether to stop error propagation on the input Deferred objects. If the
DeferredList sees an error from one of the Deferred inputs, the error will
be captured, and the Deferred will be returned to success state with a null
return value.
|
Code » | |
![]()
The stored return values of the Deferred objects.
|
Code » | |
![]()
Whether to fire on the first successful callback instead of waiting for
every Deferred to complete.
|
Code » | |
![]()
Whether to fire on the first error result received instead of waiting for
every Deferred to complete.
|
Code » | |
![]()
The list of Deferred objects to wait for.
|
Code » | |
![]()
The number of input deferred objects that have fired.
|
Code » |
![]()
Whether the Deferred is blocked waiting on another Deferred to fire. If a
callback or errback returns a Deferred as a result, the execution sequence
is blocked until that Deferred result becomes available.
|
Code » | |
![]()
Whether this Deferred is blocking execution of another Deferred. If this
instance was returned as a result in another Deferred's execution
sequence,that other Deferred becomes blocked until this instance's
execution sequence completes. No additional callbacks may be added to a
Deferred once it is blocking another instance.
|
Code » | |
![]()
The number of Deferred objects that have been branched off this one. This
will be decremented whenever a branch is fired or canceled.
|
Code » | |
![]()
Holds the stack trace at time of deferred creation if the JS engine
provides the Error.captureStackTrace API.
|
Code » | |
![]()
The default scope to execute callbacks and errbacks in.
|
Code » | |
![]()
Whether the Deferred has been fired.
|
Code » | |
![]()
Whether the last result in the execution sequence was an error.
|
Code » | |
![]()
Optional function that will be called if the Deferred is canceled.
|
Code » | |
If this Deferred was created by branch(), this will be the "parent"
Deferred.
|
Code » | |
![]()
The current Deferred result, updated as callbacks and errbacks are
executed.
|
Code » | |
![]()
Entries in the sequence are arrays containing a callback, an errback, and
an optional scope. The callback or errback in an entry may be null.
|
Code » | |
![]()
Whether the Deferred has been canceled without having a custom cancel
function.
|
Code » | |
![]()
If an error is thrown during Deferred execution with no errback to catch
it, the error is rethrown after a timeout. Reporting the error after a
timeout allows execution to continue in the calling context (empty when
no error is scheduled).
|
Code » |
Creates a
DeferredList that gathers results from multiple
Deferred inputs. If all inputs succeed, the callback is fired
with the list of results as a flat array. If any input fails, the list's
errback is fired immediately with the offending error, and all other pending
inputs are canceled.
Arguments:
Returns: !goog.async.Deferred
The deferred list of results from the inputs
if they all succeed, or the error result of the first input to fail.
|
code » |
![]()
No description.
|
Code » |