@ngxs-labs/entity-state
Version:
<p align="center"> <img src="https://raw.githubusercontent.com/ngxs-labs/emitter/master/docs/assets/logo.png"> </p>
32 lines (31 loc) • 1.44 kB
TypeScript
import { StateOperator } from '@ngxs/store';
import { Dictionary } from '../internal';
import { EntityStateModel } from '../models';
import { EntityUpdate, Updater } from '../actions';
export declare type OnUpdate<T> = (current: Readonly<T>, updated: Partial<T>) => T;
/**
* Updates the given entities in the state.
* Entities will be merged with the given `onUpdate` function.
* @param payload the updated entities
* @param idKey key of the id-field of an entity
* @param onUpdate update function to call on each entity
*/
export declare function update<T>(payload: EntityUpdate<T>, idKey: string, onUpdate: OnUpdate<T>): StateOperator<EntityStateModel<T>>;
export declare function updateActive<T>(payload: Updater<T>, idKey: string, onUpdate: OnUpdate<T>): (state: EntityStateModel<T>) => {
entities: Dictionary<T>;
lastUpdated: number;
loading: boolean;
error: Error;
active: string;
ids: string[];
pageSize: number;
/**
* Updates the given entities in the state.
* Entities will be merged with the given `onUpdate` function.
* @param payload the updated entities
* @param idKey key of the id-field of an entity
* @param onUpdate update function to call on each entity
*/
pageIndex: number;
};
export declare function updateDictionary<T>(entities: Dictionary<T>, entity: Partial<T>, id: string, onUpdate: OnUpdate<T>): Dictionary<T>;