Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.01 KB

interfaces.md

File metadata and controls

41 lines (29 loc) · 1.01 KB

Entity Interfaces

EntityState

The Entity State is a predefined generic interface for a given entity collection with the following interface:

interface EntityState<V> {
  ids: string[] | number[];
  entities: { [id: string | id: number]: V };
}
  • ids: An array of all the primary ids in the collection
  • entities: A dictionary of entities in the collection indexed by the primary id

Extend this interface to provided any additional properties for the entity state.

Usage:

 export interface User {
  id: string;
  name: string;
}

export interface State extends EntityState<User> {
  // additional entity state properties
  selectedUserId: number | null;
}

EntityAdapter

Provides a generic type interface for the provided entity adapter. The entity adapter provides many collection methods for managing the entity state.

Usage:

export const adapter: EntityAdapter<User> = createEntityAdapter<User>();