UNPKG

@ngxs-labs/entity-state

Version:

<p align="center"> <img src="https://raw.githubusercontent.com/ngxs-labs/emitter/master/docs/assets/logo.png"> </p>

27 lines (26 loc) 1.03 kB
import { Dictionary } from './internal'; /** * Interface for an EntityState. * Includes the entities in an object literal, the loading and error state and the ID of the active selected entity. */ export interface EntityStateModel<T> { entities: Dictionary<T>; loading: boolean; error: Error | undefined; active: string | undefined; ids: string[]; pageSize: number; pageIndex: number; lastUpdated: number; } export declare type StateSelector<T> = (state: EntityStateModel<any>) => T; export declare type DeepReadonly<T> = T extends (infer R)[] ? DeepReadonlyArray<R> : T extends Function ? T : T extends object ? DeepReadonlyObject<T> : T; export interface DeepReadonlyArray<T> extends Array<DeepReadonly<T>> { } export declare type DeepReadonlyObject<T> = { readonly [P in keyof T]: DeepReadonly<T[P]>; }; /** * Function that provides an ID for the given entity */ export declare type IdProvider<T> = (entity: Partial<T>, state: EntityStateModel<T>) => string;