export type QueryFunction = (value: T) => boolean; export type CollectionEventCallback = (collection: ICollection) => void; export type CollectionDataEventCallback = (collection: ICollection, ...items: T[]) => void; export interface ICollection { indexName: string; readonly count: number; get(id: string): T | undefined; getAll(): T[]; getAllKeys(): string[]; where(condition: QueryFunction): T[]; contains(id: string): boolean; add(...items: T[]): void; remove(id: string): void; removeAll(): void; onBeforeAdd(callback: CollectionDataEventCallback): void; onAdd(callback: CollectionEventCallback): void; onBeforeRemove(callback: CollectionEventCallback): void; onRemove(callback: CollectionEventCallback): void; onBeforeRemoveAll(callback: CollectionEventCallback): void; onRemoveAll(callback: CollectionEventCallback): void; } export interface IIndexedByString { [index: string]: T; }