@datorama/akita
Version:
State Management Tailored-Made for JS Applications
17 lines (16 loc) • 637 B
TypeScript
import { ArrayProperties, IDS, ItemPredicate } from './types';
/**
* Update item in a collection
*
* @example
*
*
* store.update(1, entity => ({
* comments: arrayUpdate(entity.comments, 1, { name: 'newComment' })
* }))
*/
export declare function arrayUpdate<Root extends any[], Entity = any>(keyOrRoot: Root, predicateOrIds: IDS | ItemPredicate<Root[0]>, obj: Partial<Root[0]>, idKey?: string): Root[0][];
/**
* @deprecated
*/
export declare function arrayUpdate<Root, Entity = any>(keyOrRoot: ArrayProperties<Root>, predicateOrIds: IDS | ItemPredicate<Entity>, obj: Partial<Entity>, idKey?: string): (state: Root) => Root;