EsAsyncPromise
Description
A way to produce EsFuture objects and asynchronously complete them later with a value or error.
The promise completes the future asynchronously. That means that callbacks registered on the future are not called immediately when #complete: or #completeError: is called. Instead, the callbacks are delayed until later using EsAsyncTaskScheduler>>scheduleTask:.
This promise is intended to be instantiated by calling EsPromise new or EsPromise async.
Also see additional comments in EsPromise>>new and EsPromise>>async
Examples
| promise |
promise := EsPromise sync.
promise future then: [:v | self assert: [v = 42]].
promise complete: 42.
Class Methods
None
Instance Methods
complete:
Complete the future asynchronously with the supplied value @aValue.
@see EsPromise>>complete: for more details
Arguments:
aValue - <Object>
Raises:
<EsAsyncStateError>
isCompleted
The future's #isComplete doesn't take into account pending completions.
Therefore #mayComplete is used.
@see EsPromise>>isCompleted for more details
Answers:
<Boolean>
Last modified date: 04/21/2022