import type { Entities, PartialEntity, Subtree } from '../types'; import { EntitiesMap } from './entities-map'; export { EntitiesMap } from './entities-map'; declare type SubtreeHandlers = { get(): Subtree; set(next: Subtree): void; }; declare type EntityLens = Lens, PartialEntity>; declare class Lens { readonly get: (obj: Base) => GetData; readonly set: (obj: Base, next: SetData) => Base; static forSubtreeEntity(entityId: string): EntityLens; constructor(get: (obj: Base) => GetData, set: (obj: Base, next: SetData) => Base); deepMerge(fallback: NextGetData): Lens; refine(get: (u: GetData) => RefinedGetData, set: (u: GetData, v: RefinedSetData) => SetData): Lens; } /** * Binds a Lens, PartialEntity> to side-effectful handlers so * that getting the current state of the subtree and setting updates can be done without * passing around the triple of [Lens, Subtree, OnUpdateFn] */ export declare class BoundSubtreeLens { private readonly lens; private readonly handlers; static forEntity(entityId: string, handlers: SubtreeHandlers): BoundSubtreeLens; constructor(lens: EntityLens, handlers: SubtreeHandlers); get(): PartialEntity; getDeepCopy(): PartialEntity; set(next: PartialEntity, newEntities?: Entities): void; /** * @todo: Replace this function with the new global state update functionality when it * becomes available. * * This is a special case of set() that allows for multiple updates to be applied * atomically and to external entities. This is useful for cases where you want to update * multiple entities as one action * * @param actions - an array of functions that take the current tree and return a new one */ setCombinedActions(actions: ((tree: Subtree) => { entityId: string; next: Partial>; } | undefined)[]): void; editDraft(fn: (entity: PartialEntity, entitiesMap: EntitiesMap) => void): void; deepMerge(fallback: PartialEntity): BoundSubtreeLens; /** * Refines the lens so that it will return a subset of entity data and overrides. */ refineByKey(key: K): BoundSubtreeLens; /** * Creates a new instance of `BoundSubtreeLens` to bust referential equality checks */ clone(): BoundSubtreeLens; }