Type deai:Promise

A pending value

This encapsulates a pending value. Once this value become available, a “resolved” signal will be emitted with the value. Each promise should resolve only once ever.

See event.any_promise, event.join_promises, event.new_promise, event.ready_promise, Promise.catch, Promise.then for more information about this type

Methods

catch(handler)

Catch promise rejections

then(handler)

Chain computation to a promise

catch(handler) Promise
Return type:

Promise

Parameters:

handler (object)

Catch promise rejections

Create a new promise that resolves when the given promise rejects. The handler will be called with the rejection value, and its return value will be what the returned promise resolves to.

then(handler) Promise
Return type:

Promise

Parameters:

handler (object)

Chain computation to a promise

Register a handler to be called after promise resolves, the handler will be called with the resolved value as argument.

Returns a promise that will be resolved after handler returns. If handler returns another promise, then the promise returned by this function will resolve after the promise returned by the handler resolves, otherwise the returned promise will resolve to the value returned by the handler.

Note the handler will always be called after being registered, whether the promise returned by this function is freed or not.

(this function is also available as “then_”, since “then” is a keyword in lua)