Interface Dispatch<T>

interface Dispatch {
    apply(type, that?, args?): void;
    call(type, that?, ...args): void;
    copy(): Dispatch<T>;
    on(typenames): ((this, ...args) => void);
    on(typenames, callback): Dispatch<T>;
}

Type Parameters

  • T extends object

Methods

Methods

  • Like function.apply, invokes each registered callback for the specified type, passing the callback the specified arguments, with that as the this context.

    Parameters

    • type: string

      A specified event type.

    • Optional that: T

      The this context for the callback.

    • Optional args: any[]

      Additional arguments to be passed to the callback.

    Returns void

    Throws

    "unknown type" on unknown event type.

  • Like function.call, invokes each registered callback for the specified type, passing the callback the specified arguments, with that as the this context. See dispatch.apply for more information.

    Parameters

    • type: string

      A specified event type.

    • Optional that: T

      The this context for the callback.

    • Rest ...args: any[]

      Additional arguments to be passed to the callback.

    Returns void

    Throws

    "unknown type" on unknown event type.

  • Returns a copy of this dispatch object. Changes to this dispatch do not affect the returned copy and vice versa.

    Returns Dispatch<T>

  • Returns the callback for the specified typenames, if any. If multiple typenames are specified, the first matching callback is returned.

    Parameters

    • typenames: string

    Returns ((this, ...args) => void)

      • (this, ...args): void
      • Parameters

        • this: T
        • Rest ...args: any[]

        Returns void

  • Adds or removes the callback for the specified typenames. If a callback function is specified, it is registered for the specified (fully-qualified) typenames. If a callback was already registered for the given typenames, the existing callback is removed before the new callback is added. The specified typenames is a string, such as start or end.foo. The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered to receive events of the same type, such as start.foo and start.bar. To specify multiple typenames, separate typenames with spaces, such as start end or start.foo start.bar. To remove all callbacks for a given name foo, say dispatch.on(".foo", null).

    Parameters

    • typenames: string
    • callback: ((this, ...args) => void)
        • (this, ...args): void
        • Parameters

          • this: T
          • Rest ...args: any[]

          Returns void

    Returns Dispatch<T>