The goog.labs.result.Result Interface

goog.labs.result.Result()

A Result object represents a value returned by an asynchronous operation at some point in the future (e.g. a network fetch). This is akin to a 'Promise' or a 'Future' in other languages and frameworks. @interface

unhandled information:

type
'interface'

The goog.labs.result.Result.CancelError Class

The value to be passed to the error handlers invoked upon cancellation. … more

The goog.labs.result.Result.State Enum

The States this object can be in. … more

.cancel()

Cancels the current Result, invoking the canceler function, if set.

returns {boolean}
Whether the Result was canceled.

.getError()

returns {*}
The error slug for this Result. Will return undefined if the Result was a success, the error slug was not set, or if the Result is pending.

.getState()

returns {!goog.labs.result.Result.State}
The state of this Result.

.getValue()

returns {*}
The value of this Result. Will return undefined if the Result is pending or was an error.

.isCanceled()

returns {boolean}
Whether this Result was canceled.

.wait(handler)

Attaches handlers to be called when the value of this Result is available.

handler {!function(!goog.labs.result.Result)}
The function called when the value is available. The function is passed the Result object as the only argument.