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 .Error | The Error message (if there are any) of the promise if it is resulted in Error state. |
Promise .Result | The result of the promise if it is fulfilled and a result expected. Nil otherwise. |
Promise .State | State of the current promise. |
Methods
Name | Description |
---|---|
Promise .Catch(onError) | 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) | 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.