turbodombuilder - v0.9.5
    Preparing search index...

    Class TurboEmitter<ModelType>

    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, Map<string, ((...args: any[]) => void)[]>> = ...

    Map containing all callbacks.

    model?: ModelType

    The attached MVC model.

    Methods

    • Protected

      getBlock

      Parameters

      • OptionalblockKey: string | number

        The key of the block to retrieve.

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

      Retrieves the callback block by the given blockKey.

    • Protected

      getOrGenerateBlock

      Parameters

      • OptionalblockKey: string | number

        The block key.

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

      • The ensured callback map.

      Retrieves or creates a callback map for a given blockKey.

    • Protected

      getKey

      Parameters

      • key: string

        The event name.

      • OptionalblockKey: string | number

        The block in which the event is scoped.

      Returns ((...args: any[]) => void)[]

      • An array of callbacks for that event.

      Gets all callbacks for a given event key within a block.

    • Protected

      getOrGenerateKey

      Parameters

      • key: string

        The event name.

      • OptionalblockKey: string | number

        The block in which the event is scoped.

      Returns ((...args: any[]) => void)[]

      • An array of callbacks for that event.

      Ensures and returns the array of callbacks for a given event key within a block.

    • addWithBlock

      Parameters

      • key: string

        The event name.

      • blockKey: string | number

        The block to register the event in.

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

        The callback function to invoke when the event is fired.

      Returns void

      Registers a callback for an event key within a specified block -- usually for the corresponding data block in the model.

    • add

      Parameters

      • key: string

        The event name.

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

        The callback function.

      Returns void

      Registers a callback for an event key in the default block.

    • removeWithBlock

      Parameters

      • key: string

        The event name.

      • blockKey: string | number

        The block from which to remove the event.

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

        The specific callback to remove. If undefined, all callbacks for the key are removed.

      Returns void

      Removes a specific callback or all callbacks for a key within a block.

    • remove

      Parameters

      • key: string

        The event name.

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

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

      Returns void

      Removes a specific callback or all callbacks for a key in the default block.

    • fireWithBlock

      Parameters

      • key: string

        The event name.

      • blockKey: string | number

        The block in which the event is scoped.

      • ...args: any[]

        Arguments passed to each callback.

      Returns void

      Triggers all callbacks associated with an event key in a specified block.

    • fire

      Parameters

      • key: string

        The event name.

      • ...args: any[]

        Arguments passed to the callback.

      Returns void

      Triggers all callbacks associated with an event key in the default block.