MVVM Object wrapper. Emmits change after setData

Type Parameters

Hierarchy (View Summary)

Implements

Constructors

Properties

_data: T
_debounce: number
_dropChanges: Subject<void>
_prevData: () => T
emit: (eventName: EventKey, ...args: any[]) => Promise<void>

Emits the given event with the specified arguments.

Type declaration

    • (eventName: EventKey, ...args: any[]): Promise<void>
    • Parameters

      • eventName: EventKey

        The name of the event to emit.

      • ...args: any[]

        The arguments to pass to the event listeners.

      Returns Promise<void>

      • A promise that resolves when all event listeners have completed.
getListeners: (key: EventKey) => Function[]

Retrieves the listeners associated with the given event key.

Type declaration

    • (key: EventKey): Function[]
    • Parameters

      • key: EventKey

        The event key to retrieve the listeners for.

      Returns Function[]

      An array of listeners associated with the given event key.

handleChange: (change: (item: Entity<T>) => void) => () => void

Handles change events.

Type declaration

    • (change: (item: Entity<T>) => void): () => void
    • Parameters

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

        The change event handler function.

      Returns () => void

      • The function to unregister the change event.
handleDropChanges: () => void

Handles the changes when an item is dropped.

Type declaration

    • (): void
    • Returns void

handleDropChanges

ClassName

once: (eventName: EventKey, callback: Function) => () => void

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

Type declaration

    • (eventName: EventKey, callback: Function): () => void
    • 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.
refresh: () => Promise<void>

A function that triggers a refresh event.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

global

setData: (data: Partial<T> | (prevData: T) => Partial<T>) => void

Sets the data for the given variable.

Type declaration

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

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

        The data to be set. This can either be a partial object of type T or a function that takes the previous data of type T and returns a partial object of type T.

      Returns void

subscribe: (eventName: EventKey, callback: Function) => void

Subscribes a callback function to the specified event name.

Type declaration

    • (eventName: EventKey, callback: Function): void
    • Parameters

      • eventName: EventKey

        The key of the event.

      • callback: Function

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

      Returns void

toObject: () => T

Converts the object into a plain JavaScript object.

Type declaration

    • (): T
    • Returns T

      • The plain JavaScript object representation.
unsubscribe: (eventName: EventKey, callback: Function) => void

Removes a callback function from the list of event listeners for the specified event.

Type declaration

    • (eventName: EventKey, callback: Function): void
    • Parameters

      • eventName: EventKey

        The key of the event to unsubscribe from.

      • callback: Function

        The callback function to remove from the event listeners.

      Returns void

unsubscribeAll: () => void

Clears all event handlers registered for the current object.

Type declaration

    • (): void
    • Returns void

Accessors

  • get hasListeners(): boolean

    Check if the object has any listeners attached to it.

    Returns boolean

    True if the object has listeners, false otherwise.

  • get id(): string | number

    Retrieves the id value from the data object.

    Returns string | number

    The id value.