EsAsyncPromise
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
EXAMPLE
| 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>
completeError:stackTrace:
Complete the future asynchronously with the supplied error @anError
and @aStackTrace
@see EsPromise>>completeError: for more details
Arguments:
anError - <Object>
aStackTrace - <EsAsyncStackTrace>
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: 02/23/2021