turbodombuilder - v0.9.22
    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

    • Type Parameters

      • ModelType extends TurboModel<
            any,
            any,
            any,
            "map"
            | "array",
            TurboDataBlock<any, any, any, any, any>,
        > = TurboModel<
            any,
            any,
            any,
            "map"
            | "array",
            TurboDataBlock<any, any, any, any, any>,
        >

      Parameters

      Returns TurboEmitter<ModelType>

    Properties

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

    Map containing all callbacks.

    model?: ModelType

    The attached MVC model.

    Methods

    • Protected Function

      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 Function

      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 Function

      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 Function

      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.

    • Function

      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.

    • Function

      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.

    • Function

      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.

    • Function

      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.

    • Function

      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.

    • Function

      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.