Represents an interface for an entity adapter.

interface IEntityAdapter<T extends IEntity = any> {
    data: T;
    id: string | number;
    refresh(): void;
    setData(data: Partial<T> | (prevData: T) => Partial<T>): void;
    toObject(): T;
}

Type Parameters

  • T extends IEntity = any

    The type of the entity.

Implemented by

Properties

Methods

Properties

data: T

Represents a variable of type T.

T - The type of data stored in the variable.

id: string | number

An identifier representing the unique identity of an entity.

Methods

  • Refreshes the view or data associated with the current state. This method internally handles the logic to update the view or fetch the latest data based on the current state of the application. Note that this method does not return any value.

    Returns void

    refresh

  • Sets the data for the given object.

    Parameters

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

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

    Returns void

  • Converts the current object to its corresponding type T.

    Returns T

    The converted object of type T.