async

Classes

goog.async.AnimationDelay
A delayed callback that pegs to the next animation frame instead of a user configurable timeout. By design, this should have the same interface as goog.async.Delay. Uses requestAnimationFrame and friends when available, but falls back to a timeout of goog.async.AnimationDelay.TIMEOUT. For more on requestAnimationFrame and how you can use it to create smoother animations, see:
goog.async.ConditionalDelay
A ConditionalDelay object invokes the associated function after a specified interval delay and checks its return value. If the function returns 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.
goog.async.Deferred
A Deferred represents the result of an asynchronous operation. A Deferred instance has no result when it is created, and is "fired" (given an initial result) by calling 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.
goog.async.DeferredList
Constructs an object that waits on the results of multiple asynchronous operations and marshals the results. It is itself a 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.Delay
A Delay object invokes the associated function after a specified delay. The interval duration can be specified once in the constructor, or can be defined each time the delay is started. Calling start on an active delay will reset the timer.
goog.async.Throttle
Throttle will perform an action that is passed in no more than once per interval (specified in milliseconds). If it gets multiple signals to perform the action while it is waiting, it will only perform the action once at the end of the interval.

Public Protected Private

Global Functions

goog.async.nextTick(callbackopt_context)
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:
callback : function(this:SCOPE)
Callback function to fire as soon as possible.
opt_context : SCOPE=
Object in whose scope to call the listener.
code »
goog.async.run(callbackopt_context)
Fires the provided callback just before the current callstack unwinds, or as soon as possible after the current JS execution context.
Arguments:
callback : function(this:THIS)
No description.
opt_context : THIS=
Object to use as the "this value" when calling the provided function.
code »
goog.async.throwException(exception)
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:
exception : *
No description.
code »

Global Properties

goog.async.AnimationDelayTest :
No description.
Code »
goog.async.ConditionalDelayTest :
No description.
Code »
goog.async.DelayTest :
No description.
Code »
goog.async.ThrottleTest :
No description.
Code »
goog.async.nextTickTest :
No description.
Code »
goog.async.runTest :
No description.
Code »

Package async

Package Reference