import Interactions from './Interactions'; export declare type EntityMap = { [key: string]: T; }; export interface ModelConstructor { toModel(data: {}): {}; } /** * Handles common behavior for a collection of entities. */ export default class EntityCollection extends Interactions { /** * Ensures that all entities managed by the collection are instances of the * Model. * * You generally want to call this after restoring state, and before * initializing the store. */ transformState(fullState: {}): {}; getAll(scopedState: EntityMap): EntityMap; getAllIds(scopedState: EntityMap): string[]; getById(scopedState: EntityMap, id: string): T | void; /** * Replaces _all_ entities currently in the collection with a new set. */ setAll(scopedState: EntityMap, entities: T | T[]): EntityMap; /** * Adds `entities` to the collection, overwriting their previous values, but * does not modify any other entities already in the collection. */ set(scopedState: EntityMap, entities: T | T[]): EntityMap; /** * Takes partial entities (deltas), and merges their data into the entities * already in the collection. * * Values are shallow merged. */ update(scopedState: EntityMap, deltas: T | T[]): EntityMap; delete(scopedState: EntityMap, identities: string | string[]): EntityMap; /** * If a model is specified, it will be used to transform entities into * instances of that model, rather than storing plain old objects. */ Model: ModelConstructor; /** * Retrieves the identity of a particular entity. */ getIdentity(entity: T): string; /** * Determines whether two entities are equal (before transformation). */ isEqual(entityA: T, entityB: T): boolean; /** * Coerces entity data into an instance of its model. */ transform(entity: T): T; /** * Constructs an EntityMap for `entities`, but is careful to only create new * objects where necessary. */ _transformAndIndexUpdates(entities: T[], existingEntities: EntityMap, includeExisting?: boolean): EntityMap; }