Interface ContextManager

interface ContextManager {
    active(): Context;
    bind<T>(context?, target): T;
    disable(): this;
    enable(): this;
    with<A, F>(context, fn, thisArg?, ...args): ReturnType<F>;
}

Methods

  • Get the current active context

    Returns Context

  • Bind an object as the current context (or a specific one)

    Type Parameters

    • T

    Parameters

    • Optional context: Context

      Optionally specify the context which you want to assign

    • target: T

      Any object to which a context need to be set

    Returns T

  • Disable context management

    Returns this

  • Enable context management

    Returns this

  • Run the fn callback with object set as the current active context

    Type Parameters

    • A extends unknown[]
    • F extends ((...args) => ReturnType<F>)

    Parameters

    • context: Context

      Any object to set as the current active context

    • fn: F

      A callback to be immediately run within a specific context

    • Optional thisArg: ThisParameterType<F>

      optional receiver to be used for calling fn

    • Rest ...args: A

      optional arguments forwarded to fn

    Returns ReturnType<F>