opx_lib
Lib.Async
Last updated on
Wait on several promises at once.
No permission. Create every promise first, then pass them in. Yields.
Lib.Async.All
Waits for every promise; fails at the first rejection.
Lib.Async.All(promises)Parameters
- promises:
table— a list of promises
Returns
Result— the list of first values; on failureatis the failing index- errors
invalid_promises,not_a_promise, or the rejection
- errors
CreateThread(function()
local a = Lib.Callback.Ask('my_shop:stock', 'water')
local b = Lib.Callback.Ask('my_shop:stock', 'burrito')
local both = Lib.Async.All({ a.value, b.value })
if both.ok then print(both.value[1], both.value[2]) end
end)Lib.Async.Settled
Waits for every promise and reports each.
Lib.Async.Settled(promises)Parameters
- promises:
table
Returns
Result— a list of Results (a non-promise entry isnot_a_promise); errorinvalid_promises