Hook defines a concurrent safe structure for handling event hooks (aka. callbacks propagation).

Type Parameters

  • T

Hierarchy

  • Hook

Methods

  • Add registers a new handler to the hook by appending it to the existing queue.

    Returns an autogenerated hook id that could be used later to remove the hook with Hook.Remove(id).

    Parameters

    Returns string

  • PreAdd registers a new handler to the hook by prepending it to the existing queue.

    Returns an autogenerated hook id that could be used later to remove the hook with Hook.Remove(id).

    Parameters

    Returns string

  • Remove removes a single hook handler by its id.

    Parameters

    • id: string

    Returns void

  • RemoveAll removes all registered handlers.

    Returns void

  • Trigger executes all registered hook handlers one by one with the specified data as an argument.

    Optionally, this method allows also to register additional one off handlers that will be temporary appended to the handlers queue.

    The execution stops when:

    • hook.StopPropagation is returned in one of the handlers
    • any non-nil error is returned in one of the handlers

    Parameters

    Returns void

Generated using TypeDoc