turbodombuilder - v0.9.66
    Preparing search index...

    Class TurboEmitter<ModelType, DataKeyType>

    TurboEmitter

    The base MVC emitter class. Its role is basically an event bus. It allows the different parts of the MVC structure to fire events or listen to some, with various methods.

    Type Parameters

    Index

    Constructors

    Properties

    callbacks: Map<string, Delegate<(...args: any[]) => void>> = ...

    Map containing all custom callbacks.

    dataCallbacks: Map<
        FlatKeyType,
        Delegate<(value: any, ...keys: DataKeyType[]) => void>,
    > = ...

    Map containing all data callbacks.

    model?: ModelType

    The attached MVC model.

    Methods

    • Function

      add

      Parameters

      • event: string

        The event name.

      • callback: (...args: any[]) => void

        The callback to invoke when the event fires.

      Returns void

      Register a callback for the given event name.

    • Function

      remove

      Parameters

      • event: string

        The event name.

      • Optionalcallback: (...args: any[]) => void

        The callback to remove. If omitted, all callbacks for the event are removed.

      Returns void

      Remove a specific callback from the given event, or all callbacks if omitted.

    • Function

      fire

      Parameters

      • event: string

        The event name.

      • ...args: any[]

        Arguments passed to each callback.

      Returns void

      Trigger all callbacks registered for the given event name.

    • Function

      addKey

      Parameters

      • callback: (value: any, ...keys: DataKeyType[]) => void

        The callback to register.

      • ...keys: DataKeyType[]

        Ordered path from outermost to innermost key.

      Returns void

      Register a callback fired when the entry at the given key path changes in the model. The callback receives the new value as its first argument, followed by the key path as spread arguments.

    • Function

      removeKey

      Parameters

      • Optionalcallback: (value: any, ...keys: DataKeyType[]) => void

        The callback to remove. If omitted, all callbacks for this path are removed.

      • ...keys: DataKeyType[]

        Ordered path from outermost to innermost key.

      Returns void

      Remove a specific callback for the given key path, or all callbacks if omitted.

    • Function

      fireKey

      Parameters

      • value: any

        The new value at the key path.

      • ...keys: DataKeyType[]

        Ordered path from outermost to innermost key.

      Returns void

      Trigger all callbacks registered for the given key path. Called automatically when the model fires a change notification at this path.

    • Protected Function

      resolveFlatKey

      Parameters

      Returns FlatKeyType

      Convert a key path to a stable flat string key for internal storage lookup. Joins with "|".