The Store class defines a local data store, and provides methods to retrieve data from the API.

Hierarchy

  • Store

Constructors

Properties

data: StoreData = {}

The local data store. A tree of resource types to IDs, such that accessing data[type][id] will return the model for that type/ID.

models: Record<string, (new () => Model)>

The model registry. A map of resource types to the model class that should be used to represent resources of that type.

Type declaration

Methods

  • Get a record from the store by the value of a model attribute.

    Type Parameters

    • M extends Model<M>

    • T = unknown

    Parameters

    • type: string

      The resource type.

    • key: keyof M

      The name of the method on the model.

    • value: T

      The value of the model attribute.

    Returns undefined | M

  • Create a model to represent a resource object (or update an existing one), and push it into the store.

    Type Parameters

    Parameters

    Returns null | M

    The model, or null if no model class has been registered for this resource type.

Generated using TypeDoc v0.24.8