A Promise represents a value that may not yet be computed. Any object that implements TAsyncPromise Trait named: #TAsyncPromise instanceVariableNames: '' package: 'Futures-Base - Promises' can be used as a Promise.

Promise combinators

Promises can be chained and the type of the new chained promise depends on the state of chainable promise. In total there are the following kinds of Promises:

Fulfilled promise

A Promise created from an existing value or a promise whose computation is succesfully finished is called fulfilled:

	^ 42 asAsyncPromise

Rejected promise

A Promise created from an Exception Object subclass: #Exception instanceVariableNames: 'messageText tag signaler signalContext handlerContext outerContext' classVariableNames: '' package: 'Kernel-Exceptions' or a promise whose computation failed is called rejected:

	^ [ 1/ 0 ] on: Error do: #asAsyncPromise

Pending promise

A Promise with a not yet computed value is called pending. Once computation is finished a pending promise becomes fulfilled or rejected:

	^ [ 2 seconds wait. 'Promised value' ] asAsyncPromise
	^ [ 2 seconds wait. 1 / 0 ] asAsyncPromise