Stack Context Manager for managing the state in web it doesn't fully support the async calls though

Implements

Constructors

Properties

Methods

Constructors

Properties

_currentContext: Context = ROOT_CONTEXT

Keeps the reference to current context

Methods

  • Binds a the certain context or the active one to the target function and then returns the target

    Type Parameters

    • T

    Parameters

    • context: Context

      A context (span) to be bind to target

    • target: T

      a function or event emitter. When target or one of its callbacks is called, the provided context will be used as the active context for the duration of the call.

    Returns T

  • Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window. The context will be set as active

    Type Parameters

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

    Parameters

    • context: null | Context
    • fn: F

      Callback function

    • OptionalthisArg: ThisParameterType<F>

      optional receiver to be used for calling fn

    • ...args: A

      optional arguments forwarded to fn

    Returns ReturnType<F>