x4js - v2.2.49
    Preparing search index...

    Class DataProxy

    CoreElement

    A lightweight base class that provides two orthogonal utilities commonly needed by UI or domain objects:

    1. Named timers (wraps setTimeout / setInterval by name so they can be started, stopped, and cleared by string identifier), and
    2. A typed eventing surface (lazy-initialised EventSource) for attaching, detaching and firing events.

    The class is generic over an EventMap E which maps event name keys to the payload type for that event. This enables compile-time type safety for listeners and fired events.

    Template parameters:

    Hierarchy (View Summary)

    Index
    • Clears all timeouts and intervals currently managed by this instance. This stops all scheduled callbacks and removes their references.

      Returns void

      setTimeout

    • Dispatches an event with a given name and payload to all registered listeners. If no listeners are registered for the event name, or if no EventSource has been initialized, this method does nothing.

      Type Parameters

      • K extends "change"

      Parameters

      • name: K

        The name of the event to fire.

      • ev: DataEventMap[K]

        The payload (event object) to pass to the listeners.

      Returns void

      • on
      • off
    • Removes a previously registered event listener. If the listener was not found or no events were registered, this method does nothing.

      Type Parameters

      • K extends "change"

      Parameters

      • name: K

        The name of the event from which to remove the listener.

      • listener: (ev: DataEventMap[K]) => void

        The specific listener function to remove.

      Returns void

      • on
      • fire
    • Registers an event listener for a specific event name. The listener will be invoked when an event with the given name is fired. Returns an object with an off() method, which can be used to conveniently remove this specific listener.

      Type Parameters

      • K extends "change"

      Parameters

      • name: K

        The name of the event to listen for.

      • listener: (ev: DataEventMap[K]) => void

        The callback function to execute when the event is fired.

      Returns { off: () => void }

      An object containing an off() method to unsubscribe the listener.

      fire attach to an event

    • Sets an interval that repeatedly executes a callback function after a specified delay. If a timeout with the same name already exists, it will be cleared before the new one is set.

      Parameters

      • name: string

        A unique string identifier for this timeout.

      • ms: number

        The delay in milliseconds before the callback is executed.

      • callback: () => void

        The function to execute after the delay.

      Returns void

    • Sets a timeout that executes a callback function after a specified delay. If a timeout with the same name already exists, it will be cleared before the new one is set.

      Parameters

      • name: string

        A unique string identifier for this timeout.

      • ms: number

        The delay in milliseconds before the callback is executed.

      • callback: () => void

        The function to execute after the delay.

      Returns void