This class provides a simple signal dispatch mechanism. Handlers can be added, and then the dispatch method calls all of them.

If specified, Callable should be an interface containing only a callable signature returning void. Due to limitations in TypeScript, any interface containing a callable signature will be accepted by the compiler, but the resultant signature of dispatch will not be correct.

Type Parameters

  • Callable extends Function = (() => void)

Hierarchy

Constructors

Properties

Methods

Constructors

Properties

count: number = 0

Count of number of times this signal has been dispatched. This is incremented each time dispatch is called prior to invoking the handlers.

dispatch: Callable

Invokes each handler function with the same parameters (including this) with which it is called. Handlers are invoked in the order in which they were added.

handlers: Set<Callable> = ...

Methods

  • Add a handler function. If dispatch is currently be called, then the new handler will be called before dispatch returns.

    Returns

    A function that unregisters the handler.

    Parameters

    • handler: Callable

      The handler function to add.

    Returns (() => boolean)

      • (): boolean
      • Add a handler function. If dispatch is currently be called, then the new handler will be called before dispatch returns.

        Returns

        A function that unregisters the handler.

        Returns boolean

  • Remove a handler function. If dispatch is currently be called and the new handler has not yet been called, then it will not be called.

    Returns

    true if the handler was present, false otherwise.

    Parameters

    • handler: Callable

      Handler to remove.

    Returns boolean

Generated using TypeDoc