PromiseResolution object

.html ›› .html ›› .html ›› .html ››
Parent Previous Next

PromiseResolution object


While a Promise object represents an asynchronous process that can be tracked by other parts of the code, a PromiseResolution object is responsible for providing a means to resolve its associated promise, either as a success or a failure.


Characteristics

Methods

Método

Descrição

promiseResolution:setSuccess([successData])


Resolves its associated promise as a success with the provided success data.


Arguments:

  • (Optional) successData - a Lua value that will be associated as the success data of the promise.


Return:

  • A boolean value; true indicates successful resolution of the promise, while false signifies that it was not possible to resolve the promise as a success. This could occur if the promise had already been resolved to either success or failure, and its state cannot be changed further.


Remarks

  • If "successData" is a Promise object, a delegation will occur: This promiseResolution will monitor the provided promise object and whatever resolution it has, be it failure or success, this promiseResolution will also adopt.


promiseResolution:setFailure(errorMsg)


Resolves its associated promise as a failure with the provided error message.


Arguments:

  • errorMessage - a string containing the reason for the promise failure.


Return:

  • A boolean value; true indicates successful resolution of the promise, while false signifies that it was not possible to resolve the promise as a failure with the provided error message. This could occur if the promise had already been resolved to either success or failure, and its state cannot be changed further.


promiseResolution:setUserAborted()

Resolves the associated promise as a failure because the user aborted the operation


Arguments:

None


Return:

  • A boolean value; true indicates successful resolution of the promise, while false signifies that it was not possible to resolve the promise as a failure. This could occur if the promise had already been resolved to either success or failure, and its state cannot be changed further.




Remarks

Created with the Personal Edition of HelpNDoc: Easily create EPub books