Fork me on GitHub
Show:

Promise

Defined in: ../src/promise.js:7

Summary

Create a lightweight Promise for async related work.

Constructor

aeris.Promise

Defined in ../src/promise.js:7

Syntax

aeris.Promise

()

Summary

Methods

adoptState_

Syntax

adoptState_

(
  • state
  • opt_args
)
private

Summary

Mark a promise with the specified state passing in an array of arguments

Parameters:

  • state 'resolved'|'rejected'

    The state with which to mark the promise.

  • opt_args Array

    An array of responses to send to deferred callbacks.

always

Syntax

always

(
  • callback
  • opt_ctx
)

Summary

Ensure a callback is called when the promise is either resolved or rejected.

Parameters:

bindCallbackToState_

Syntax

bindCallbackToState_

(
  • state
  • callback
  • opt_ctx
)
private

Summary

Ensure a callback is called when the promise adopts the specified state.

Parameters:

done

Syntax

done

(
  • callback
  • opt_ctx
)

Summary

Ensure a callback is called when the promise is resolved.

Parameters:

fail

Syntax

fail

(
  • callback
  • opt_ctx
)

Summary

Ensure a callback is called when the promise is rejected.

Parameters:

getState

Syntax

getState

() String

Summary

Returns:

String:

The current state of the promise. 'pending', 'resolved', or 'rejected'.

proxy

Syntax

proxy

()

Summary

Resolve/reject the promise when the proxy promise is resolved/rejected.

reject

Syntax

reject

(
  • var_args
)

Summary

Mark a promise is rejected, passing in a variable number of arguments.

Parameters:

  • var_args ...*

resolve

Syntax

resolve

(
  • var_args
)

Summary

Mark a promise is resolved, passing in a variable number of arguments.

Parameters:

  • var_args ...*

    A variable number of arguments to pass to callbacks.

when

Syntax

when

(
  • var_args
)
Promise

Summary

Create a master promise from a combination of promises. Master promise is resolved when all component promises are resolved, or rejected when any single component promise is rejected.

Parameters:

  • var_args ...*

    A variable number of promises to wait for or an. array of promises.

Returns:

Promise:

Master promise.

Properties

arguments_

Syntax

arguments_

Array private

Summary

An array of arguments to send to the callbacks.

deferred_

Syntax

deferred_

Done: callbackStore, fail: callbackStore, always: callbackStore private

Summary

An object containing deferred callbacks for resolved and rejected states.

state

Syntax

state

String

Summary

The current state of the promise (e.g. pending, resolved, or rejected).