gradum-kit - v0.1.0
    Preparing search index...

    Class Delegate<CallbackType>

    Delegate

    A set of callbacks kept together and fired as one, used throughout the library wherever a component announces something (onChanged, onSelected, ...). Subscribe with Delegate.add and drop the subscription with Delegate.remove. Unlike its plain counterpart, this one announces its own subscriptions through Delegate.onAdded.

    Type Parameters

    • CallbackType extends (...args: any[]) => any

      The type of callbacks accepted by the delegate.

    Hierarchy

    Index
    • Type Parameters

      • CallbackType extends (...args: any[]) => any

        The type of callbacks accepted by the delegate.

      Returns Delegate<CallbackType>

    onAdded: SimpleDelegate<(callback: CallbackType) => void> = ...

    Fired whenever a callback is registered on this delegate, with the new callback as its argument. Use it to react to something starting to listen.

    • Function

      remove

      Parameters

      Returns boolean

      Whether the callback was registered and has been removed.

      Unregister a callback.

    • Function

      has

      Parameters

      Returns boolean

      Whether the callback is registered.

      Check whether a callback is registered.

    • Function

      fire

      Parameters

      Returns ReturnType<CallbackType>

      The last value returned by a callback, ignoring those that returned undefined.

      Invoke every registered callback with the given arguments. A callback that throws is logged and skipped, so one failure does not stop the rest.

    • Function

      clear

      Returns void

      Unregister every callback.

    • Function

      add

      Parameters

      Returns void

      Register a callback, then fire Delegate.onAdded with it.