Class representing a model.

IModelAdapter

Type Parameters

  • T extends {} = any

Hierarchy (view full)

Implements

  • IModelAdapter<T>

Constructors

  • Type Parameters

    • T extends {} = any

    Parameters

    • _data: Model<T> | T | (() => T)
    • _debounce: number = CHANGE_DEBOUNCE
    • _prevData: (() => T) = ...
        • (): T
        • Returns T

    Returns Model<T>

Properties

_data: T
_debounce: number = CHANGE_DEBOUNCE
_dropChanges: Subject<void> = ...
_prevData: (() => T) = ...

Accessors

  • get data(): T
  • Retrieves the value of the data property.

    Returns T

    The frozen data.

  • get hasListeners(): boolean
  • Check if the object has any listeners attached to it.

    Returns boolean

    True if the object has listeners, false otherwise.

Methods

  • Emits the given event with the specified arguments.

    Parameters

    • eventName: EventKey

      The name of the event to emit.

    • Rest...args: any[]

      The arguments to pass to the event listeners.

    Returns Promise<void>

    • A promise that resolves when all event listeners have completed.
  • Retrieves the listeners associated with the given event key.

    Parameters

    • key: EventKey

      The event key to retrieve the listeners for.

    Returns Function[]

    An array of listeners associated with the given event key.

  • Handles changes made to the Model.

    Parameters

    • change: ((item: Model<T>) => void)

      The callback function to be executed when a change occurs in the Model. It accepts a single parameter representing the changed item of type Model.

        • (item): void
        • Parameters

          Returns void

    Returns (() => void)

    • A cleanup function that unsubscribes the callback from the CHANGE_SYMBOL event, unsubscribes the callback from the REFRESH_SYMBOL event, clears the debounce function, and unsubscribes the drop function.
      • (): void
      • Returns void

  • Handles the changes when an item is dropped.

    Returns void

    handleDropChanges

    ClassName

  • Subscribes a callback function to the given event name. The callback function will be triggered only once when the event is emitted.

    Parameters

    • eventName: EventKey

      The name of the event to subscribe to.

    • callback: Function

      The callback function to be executed when the event is emitted.

    Returns (() => void)

    • A function that can be called to unsubscribe the callback function from the event.
      • (): void
      • Returns void

  • A function that triggers a refresh event.

    Returns Promise<void>

    global

  • Sets the data for the object.

    Parameters

    • data: Partial<T> | ((prevData: T) => Partial<T>)

      The data to be set. It can be a partial object or a function that takes the previous data and returns a partial object.

    Returns void

  • Subscribes a callback function to the specified event name.

    Parameters

    • eventName: EventKey

      The key of the event.

    • callback: Function

      The callback function to be executed when the event is triggered.

    Returns void

  • Converts the object into a plain JavaScript object.

    Returns T

    • The plain JavaScript object representation.
  • Removes a callback function from the list of event listeners for the specified event.

    Parameters

    • eventName: EventKey

      The key of the event to unsubscribe from.

    • callback: Function

      The callback function to remove from the event listeners.

    Returns void

  • Clears all event handlers registered for the current object.

    Returns void