Skip to content

API > Promise


Promise⚓︎

A Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. This allows execution of asynchronous operation in a synchronous fashion by associating handlers to eventual outcomes of the promise. A promise can result in success, rejection, or error. A promise which is not resulted in anything is in pending state.

Members⚓︎

Properties⚓︎

Name Description
Promise.ErrorPropertyReadonly Property The Error message (if there are any) of the promise if it is resulted in Error state.
Promise.ResultPropertyReadonly Property The result of the promise if it is fulfilled and a result expected. Nil otherwise.
Promise.StatePropertyReadonly Property State of the current promise.

Methods⚓︎

Name Description
Promise.Catch(onError) Method Associates a handler to be called when promise encounters an error. The Error string will be passed to associated function.
Promise.Then(onFulfill, onRejected=nil) Method Associate handlers to called when promise if fulfilled or rejected. Note that the promise invokes the associated handlers in the main game thread; therefore, every API can be used safely within handlers.

Extra Detail⚓︎

Note that the promise invokes the associated handlers in the main game thread; therefore, every API can be used safely within handlers.