A promise represents a value that may not be available yet.
The primary method for interacting with a promise is its
map()
method. A promise is a Completion
element
restricted to a single value.
no subtypes hierarchy
Initializer |
Promise() |
Attributes | |
context | Source Codeshared formal ExecutionContext context The context of this promise |
promise | Source Codeshared actual Promise<[Value]> promise The promise. Refines Promised.promise |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Promised<Value> |
Methods | |
and | Source Codeshared actual Completion<Value|Other,[Other, Value]> and<Other>(Promise<Other> other) Combine the current completion with a provided promise and return a new completion object that
The
The Promise<String> p1 = ... Promise<Integer> p2 = ... Promise<Boolean> p3 = ... p1.and(p2, p3) .compose((Boolean b, Integer i, String s) => doSomething(b, i, s)); Refines Completion.and |
completed | Source Codeshared actual void completed(Anything onFulfilled(Value val), Anything onRejected(Throwable reason)) When completion happens, the provided function will be invoked. Refines Completion.completed |
flatMap | Source Codeshared formal Promise<Result> flatMap<Result>(Promise<Result> onFulfilled(Value val), Promise<Result> onRejected(Throwable reason)) Compose and return a Refines Completion.flatMap |
map | Source Codeshared formal Promise<Result> map<Result>(Result onFulfilled(Value val), Result onRejected(Throwable reason)) Compose and return a Refines Completion.map |
onComplete | Source Codeshared void onComplete(void completed(Value|Throwable completion)) |
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Completion<Element,T> |