UNPKG

@datorama/akita

Version:

State Management Tailored-Made for JS Applications

41 lines (40 loc) 1.48 kB
import { AkitaPlugin, Queries } from '../plugin'; import { Observable } from 'rxjs'; declare type Head<State = any> = State | Partial<State>; export declare type DirtyCheckComparator<State> = (head: State, current: State) => boolean; export declare type DirtyCheckParams<StoreState = any> = { comparator?: DirtyCheckComparator<StoreState>; watchProperty?: keyof StoreState | (keyof StoreState)[]; }; export declare const dirtyCheckDefaultParams: { comparator: (head: any, current: any) => boolean; }; export declare function getNestedPath(nestedObj: any, path: string): any; export declare type DirtyCheckResetParams<StoreState = any> = { updateFn?: StoreState | ((head: StoreState, current: StoreState) => any); }; export declare class DirtyCheckPlugin<State = any> extends AkitaPlugin<State> { protected query: Queries<State>; private params?; private _entityId?; private head; private dirty; private subscription; private active; private _reset; isDirty$: Observable<boolean>; reset$: Observable<{}>; constructor(query: Queries<State>, params?: DirtyCheckParams<State>, _entityId?: any); reset(params?: DirtyCheckResetParams): void; setHead(): this; isDirty(): boolean; hasHead(): boolean; destroy(): void; isPathDirty(path: string): boolean; protected getHead(): Head<State>; private activate; private updateDirtiness; private _getHead; private getWatchedValues; } export {};