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 collectionentities
: 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;
}
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>();