@ngxs-labs/entity-state
Version:
<p align="center"> <img src="https://raw.githubusercontent.com/ngxs-labs/emitter/master/docs/assets/logo.png"> </p>
13 lines (12 loc) • 706 B
TypeScript
import { StateOperator } from '@ngxs/store';
import { EntityStateModel, IdProvider } from '../models';
/**
* Adds or replaces the given entities to the state.
* For each entity an ID will be calculated, based on the given provider.
* This operator ensures that the calculated ID is added to the entity, at the specified id-field.
* The `lastUpdated` timestamp will be updated.
* @param entities the new entities to add or replace
* @param idKey key of the id-field of an entity
* @param idProvider function to provide an ID for the given entity
*/
export declare function addOrReplace<T>(entities: T | T[], idKey: string, idProvider: IdProvider<T>): StateOperator<EntityStateModel<T>>;