result.Result Extends goog.Thenable
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.

Inheritance

Constructor

goog.result.Result()

Instance Methods

Public Protected Private
cancel() boolean
Cancels the current Result, invoking the canceler function, if set.
Returns: boolean  Whether the Result was canceled.
code »
getError() *
No description.
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.
code »
getState() !goog.result.Result.State
No description.
Returns: !goog.result.Result.State  The state of this Result.
code »
getValue() *
No description.
Returns: *  The value of this Result. Will return undefined if the Result is pending or was an error.
code »
isCanceled() boolean
No description.
Returns: boolean  Whether this Result was canceled.
code »
wait(handleropt_scope)
Attaches handlers to be called when the value of this Result is available. Handlers are called in the order they were added by wait.
Arguments:
handler : !function(this:T, !goog.result.Result)
The function called when the value is available. The function is passed the Result object as the only argument.
opt_scope : T=
Optional scope for the handler.
code »
Defined in goog.Thenable
then(opt_onFulfilledopt_onRejectedopt_context) !goog.Promise.<RESULT>
Adds callbacks that will operate on the result of the Thenable, returning a new child Promise. If the Thenable is fulfilled, the onFulfilled callback will be invoked with the fulfillment value as argument, and the child Promise will be fulfilled with the return value of the callback. If the callback throws an exception, the child Promise will be rejected with the thrown value instead. If the Thenable is rejected, the onRejected callback will be invoked with the rejection reason as argument, and the child Promise will be rejected with the return value of the callback or thrown value.
Arguments:
opt_onFulfilled : ?(function(this:THIS, TYPE): (RESULT | IThenable.<RESULT> | Thenable))=
A function that will be invoked with the fulfillment value if the Promise is fullfilled.
opt_onRejected : ?(function(this:THIS, *): *)=
A function that will be invoked with the rejection reason if the Promise is rejected.
opt_context : THIS=
An optional context object that will be the execution context for the callbacks. By default, functions are executed with the default this.
Returns: !goog.Promise.<RESULT>  A new Promise that will receive the result of the fulfillment or rejection callback.
code »

Enumerations

goog.result.Result.State :
The States this object can be in.
Constants:
ERROR
No description.
PENDING
No description.
SUCCESS
No description.
Code »

Package result

Package Reference