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| Assembly | Xantham.Fable.Node |
| Attributes | [<Interface>] |
Properties
abstract member createHook: HookCallbacks -> Function with get, set
abstract member createHook: HookCallbacks -> Function with get, setRegisters 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 | |
|---|---|
callbacks | The {@link HookCallbacks | Hook Callbacks} to register |
Returns. Used for disabling hooks
abstract member onAfter: After -> Function with get, set
abstract member onAfter: After -> Function with get, setThe 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 | |
|---|---|
after | The {@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
abstract member onBefore: Before -> Function with get, setThe 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 | |
|---|---|
before | The {@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
abstract member onInit: Init -> Function with get, setThe 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 | |
|---|---|
init | The {@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
abstract member onSettled: Settled -> Function with get, setThe 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 | |
|---|---|
settled | The {@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