Skip to content

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.

🔗 Source: src/promise.lua

MemberReturnsDescription
awaitvalue: anyBlock the current coroutine until the promise settles, then return its value
catchNormPromise (async)
nextNormPromise (async)Register handlers; returns a new chained promise.

await method

lua
NormPromise:await()
  -> value: any

Block 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)
  -> NormPromise

next async method

lua
NormPromise:next(on_fulfilled?: fun(value: any):any, on_rejected?: fun(reason: any):any)
  -> NormPromise

Register handlers; returns a new chained promise.