Async library

.html ›› .html ››
Parent Previous Next

Async library

The Async library provides functions for handling asynchronous operations, such as loading a remote node database. All of these functions are contained in the “Async” Lua table found in the “async.lua” unit.


Usage example:

-- First, you need to require the “async.lua” unit
require("async.lua");   

-- Now you can access the functions of the library.
Async.LIBRARY_FUNCTION(Argument1, Argument2, ...);


Async library functions


function Async.await(promise)
function await(promise)


Performs an asynchronous wait for the resolution of a Promise object, suspending the currently running coroutine until the provided Promise is resolved. While suspended, other coroutines and program execution lines can run, preventing the application from blocking or freezing. The coroutine execution is resumed once the given Promise is resolved to either success or failure


Reminder: Coroutines are computer program execution lines that can be suspended and resumed.


Arguments:


Return:

       When the wait is complete:


Remarks:



function Async.execute(fn, ...)


Starts the execution of a coroutine.


Reminder: Coroutines are computer program execution lines that can be suspended and resumed.


Arguments:


Return:        


Remarks:



function Async.pawait(promise)
function pawait(promise)


Similar to the await function, pawait performs an asynchronous wait for the resolution of a Promise object, suspending the currently running coroutine until the provided Promise object is resolved. However, unlike await, pawait does not automatically raise an error if the promise resolves to failure


Arguments:


Return:

       When the wait is complete, the function will return multiple values:


Remarks:

Created with the Personal Edition of HelpNDoc: Transform your help documentation into a stunning website