Preparing search index...

    Simple implementation of a key-based event class.

    Type Parameters

    • T extends unknown[]
    Index

    Constructors

    Methods

    • Add a callback function tied to the given key. The callback function will be executed when this KeyedEventWrapper is triggered using the same key.

      Parameters

      • key: string

        Key

      • callback: (...args: T) => void

        Callback function to execute

      Returns (...args: T) => void

      The callback passed in, can be used with remove()

    • Add a callback function that will be executed any time a trigger occurs. The first argument for the callback function is the key, the rest of the arguments are what get passed to the trigger.

      Parameters

      • callback: (key: string, ...args: T) => void

        Callback function to execute

      Returns (key: string, ...args: T) => void

      The callback passed in, can be used with removeAny()

    • Return an EventWrapper for the given key. The EventWrapper holds all callbacks added with the same key, and is triggered when trigger is called with the same key.

      Parameters

      • key: string

        Key

      • OptionalcreateIfMissing: boolean

        If the wrapper is missing, a new one will be created.

      Returns EventWrapper<T>

      The EventWrapper for the given key, or null if not found.

    • Remove a callback function tied to the given key.

      Parameters

      • key: string

        Key that was used to add the callback function

      • callback: (...args: T) => void

        Callback function to remove

      Returns void

    • Remove a callback function that was added using addAny().

      Parameters

      • callback: (key: string, ...args: T) => void

        Callback function to remove

      Returns void

    • Trigger all callback functions that were added using the same key. All arguments after key will be passed to the callback functions.

      Parameters

      • key: string

        Key of the events to trigger

      • ...args: T

        Arguments to pass to callbacks

      Returns void