NormPromise class
The promise wrapper every async operation returns. Await it, or chain with your framework promise.
Auto-generated
This page is generated from the source annotations by scripts/gen-api.mjs. Edit the LuaCATS doc comments in the Norm sources, not here.
| Member | Returns | Description |
|---|---|---|
await | value: any | Block the current coroutine until the promise settles, then return its value |
catch | NormPromise (async) | |
next | NormPromise (async) | Register handlers; returns a new chained promise. |
await method
lua
NormPromise:await()
-> value: anyBlock the current coroutine until the promise settles, then return its value (or raise its rejection reason). Must be called from inside a coroutine.
lua
coroutine.wrap(function()
local user = User:find(1):await()
end)()catch async method
lua
NormPromise:catch(on_rejected: fun(reason: any):any)
-> NormPromisenext async method
lua
NormPromise:next(on_fulfilled?: fun(value: any):any, on_rejected?: fun(reason: any):any)
-> NormPromiseRegister handlers; returns a new chained promise.