true
the conditional delay is cancelled and
is called. Otherwise this object keeps to invoke the deferred function until
either it returns true
or the timeout is exceeded. In the latter case
the method will be called.
The interval duration and timeout can be specified each time the delay is
started. Calling start on an active delay will reset the timer.
callback
or errback
.
Once fired, the result is passed through a sequence of callback functions
registered with addCallback
or addErrback
. The functions may
mutate the result before it is passed to the next function in the sequence.
Callbacks and errbacks may be added at any time, including after the Deferred
has been "fired". If there are no pending actions in the execution sequence
of a fired Deferred, any new callback functions will be called with the last
computed result. Adding a callback function is the only way to access the
result of the Deferred.
If a Deferred operation is canceled, an optional user-provided cancellation
function is invoked which may perform any special cleanup, followed by firing
the Deferred's errback sequence with a CanceledError
. If the
Deferred has already fired, cancellation is ignored.
Deferreds may be templated to a specific type they produce using generics
with syntax such as:
/** @type {goog.async.Deferred.} */
var d = new goog.async.Deferred();
// Compiler can infer that foo is a string.
d.addCallback(function(foo) {...});
d.callback('string'); // Checked to be passed a string
Since deferreds are often used to produce different values across a chain,
the type information is not propagated across chains, but rather only
associated with specifically cast objects.
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.
![]()
Fires the provided callbacks as soon as possible after the current JS
execution context. setTimeout(?, 0) always takes at least 5ms for legacy
reasons.
Arguments:
|
code » | |||
![]()
Fires the provided callback just before the current callstack unwinds, or as
soon as possible after the current JS execution context.
Arguments:
|
code » | |||
![]()
Throw an item without interrupting the current execution context. For
example, if processing a group of items in a loop, sometimes it is useful
to report an error while still allowing the rest of the batch to be
processed.
Arguments:
|
code » |