A Deferred
object is returned by the PromiseUtils.defer()
method to provide a new promise along with methods to change its state.
void resolve([optional] aValue); |
void reject([optional] aReason); |
Attribute | Type | Description |
promise Read only |
Promise |
A newly created promise, initially in the pending state. |
Fulfills the associated promise with the specified value, or propagates the state of an existing promise. If the associated promise has already been resolved, either to a value, a rejection, or another promise, this method does nothing.
Promise
constructor's resolve
argument, and can be called with any value of this
.aValue
argument, and then calling it again with another value before the promise is resolved or rejected, will have no effect the second time, as the associated promise is already resolved to the pending promise value as its resolution.void resolve( aValue );
aValue
Optionalundefined
, it becomes the fulfillment value of the associated promise. If this value is a promise, then the associated promise will be resolved to the passed promise, and follow the state as the provided promise (including any future transitions).Rejects the associated promise with the specified reason. If the promise has already been resolved, either to a value, a rejection, or another promise, this method does nothing.
Promise
constructor's reject
argument, and can be called with any value of this
.void reject( aReason );
aReason
OptionalThe rejection reason for the associated promise. Although the reason can be undefined
, it is generally an Error
object, like in exception handling.