Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Signal<T>

A signal is a dispatcher that can bind functions (handlers) to dispatched events.

Type parameters

  • T: Function

Hierarchy

  • Signal

Index

Methods

add

  • Binds a new handler function to this signal that will be called for each dispatch.

    Parameters

    • fn: WithVoidReturn<T>

      The handler function to bind.

    • Default value thisArg: any = null

      Optional this argument to use when calling this handler

    Returns SignalBinding

detach

  • Detaches a binding from this signal so that it is no longer called.

    Parameters

    Returns this

detachAll

  • detachAll(): this
  • Detaches all bindings.

    Returns this

dispatch

  • Dispatch an event to all handlers. If a filter was set, only if it returns true will the event get dispatched.

    Parameters

    • Rest ...args: ArgumentTypes<T>

      The arguments to pass to the filter and handlers.

    Returns boolean

    True if the event was dispatched, false otherwise.

filter

  • Sets the filter function to be called on each dispatch. This function takes the same parameters as a handler, but must return a boolean. Only when this function returns true will an event dispatch actually call bound handlers.

    Parameters

    Returns void

handlers

has

  • Returns true if the given binding is owned by this signal.

    Parameters

    Returns boolean

hasAny

  • hasAny(): boolean
  • Returns true if this signal has any bound handlers.

    Returns boolean

once

  • Binds a new handler function to this signal that will only be called once on the next dispatch.

    Parameters

    • fn: WithVoidReturn<T>

      The handler function to bind.

    • Default value thisArg: any = null

      Optional this argument to use when calling this handler.

    Returns SignalBinding

proxy

  • proxy(...signals: Signal<T>[]): this
  • Sets up a link between the passed signals and this one such that when the passed signal is dispatched, this signal is also dispatched.

    Parameters

    • Rest ...signals: Signal<T>[]

      The signals to proxy.

    Returns this

Generated using TypeDoc