Skip to content

PromiseHooks

[<Interface>]
type PromiseHooks =
    abstract member createHook: HookCallbacks -> Function with get, set
    abstract member onAfter: After -> Function with get, set
    abstract member onBefore: Before -> Function with get, set
    abstract member onInit: Init -> Function with get, set
    abstract member onSettled: Settled -> Function with get, set
    static member Create (onInit: Init -> Function, onSettled: Settled -> Function, onBefore: Before -> Function, onAfter: After -> Function, createHook: HookCallbacks -> Function) : PromiseHooks
AssemblyXantham.Fable.Node
Attributes[<Interface>]

Properties

abstract member createHook: HookCallbacks -> Function with get, set

Registers functions to be called for different lifetime events of each promise. The callbacks init()/before()/after()/settled() are called for the respective events during a promise's lifetime. All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed. The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.

@since v17.1.0, v16.14.0

Parameter
callbacksThe {@link HookCallbacks | Hook Callbacks} to register

Returns. Used for disabling hooks

abstract member onAfter: After -> Function with get, set

The after hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.

@since v17.1.0, v16.14.0

Parameter
afterThe {@link After | after callback} to call after a promise continuation executes.

Returns. Call to stop the hook.

abstract member onBefore: Before -> Function with get, set

The before hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.

@since v17.1.0, v16.14.0

Parameter
beforeThe {@link Before | before callback} to call before a promise continuation executes.

Returns. Call to stop the hook.

abstract member onInit: Init -> Function with get, set

The init hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.

@since v17.1.0, v16.14.0

Parameter
initThe {@link Init | init callback} to call when a promise is created.

Returns. Call to stop the hook.

abstract member onSettled: Settled -> Function with get, set

The settled hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.

@since v17.1.0, v16.14.0

Parameter
settledThe {@link Settled | settled callback} to call when a promise is created.

Returns. Call to stop the hook.

Methods

static member Create (onInit: Init -> Function, onSettled: Settled -> Function, onBefore: Before -> Function, onAfter: After -> Function, createHook: HookCallbacks -> Function) : PromiseHooks