export declare type StateUpdateCallback = (path: Path, newState: DeepState, oldState: DeepState) => void; export interface DeepStorage { /** * sets a value in deep storage and notifies subscribers. shortcut for * update where the old value is ignored */ set: (newValue: State) => Promise>; /** * Updates the whole state and notifies subscribers */ update: (callback: (s: State) => State) => Promise>; /** * Returns the state that this deep storage is managing */ state: State; /** * Creates a new DeepStorage at this point in the object path */ deep: (path: Key) => DeepStorage; /** * Gets the root deep storage */ root: () => DeepStorage; /** * The path from the root to this storage */ path: Path; /** * Returns an object with keys from State and values of * DeepStorage for that key */ props: { [P in keyof State]: DeepStorage; }; /** * Get the value of a property */ prop: (name: Key) => State[Key]; addSubscriber: (subscriber: Subscriber) => void; removeSubscriber: (subscriber: Subscriber) => void; } /** * Is one array a prefix on another e.g. * * [] is a prefix of any array * ['asdf'] is a prefix of ['asdf', ...] * * etc. * * @param stateChangePath the full array to check, must not be null * @param subscriptionPath the partial array to check */ export declare function isPathMatch(stateChangePath: T[], subscriptionPath: T[]): boolean; export declare type stringNumberOrSymbol = string | number | symbol; export declare type Path = stringNumberOrSymbol[]; export declare class Subscriber { private static idGenerator; id: number; private callback; constructor(); onChange(callback: StateUpdateCallback): void; change(path: Path, newState: DeepState, oldState: DeepState): void; } export declare class DefaultDeepStorage implements DeepStorage { state: State; path: Path; private subscriptions; constructor(state: State); update: (callback: (s: State) => State) => Promise>; set: (newValue: State) => Promise>; setIn: (...path: (string | number | symbol)[]) => (newValue: DeepState) => Promise>; merge: (partial: { [P in keyof State]: State[P]; }) => void; updateIn: (...path: (string | number | symbol)[]) => (callback: (s: DeepState) => DeepState) => Promise>; stateIn: (...path: (string | number | symbol)[]) => any; deepIn: (...path: (string | number | symbol)[]) => DeepStorage; deep: (name: string | number | symbol) => DeepStorage; addSubscriber: (subscriber: Subscriber) => void; addSubscriberIn: (...path: (string | number | symbol)[]) => (subscriber: Subscriber) => void; removeSubscriber: (subscriber: Subscriber) => void; removeSubscriberIn: (...path: (string | number | symbol)[]) => (subscriber: Subscriber) => void; root: () => this; readonly props: { [P in keyof State]: DeepStorage; }; prop: (name: Key) => State[Key]; } export declare class NestedDeepStorage implements DeepStorage { path: Path; rootStorage: DefaultDeepStorage; constructor(path: Path, rootStorage: DefaultDeepStorage); setIn: (...path: (string | number | symbol)[]) => (newValue: DeepState) => Promise>; set: (newValue: State) => Promise>; update: (callback: (s: State) => State) => Promise>; updateIn: (...path: (string | number | symbol)[]) => (callback: (s: DeepState) => DeepState) => Promise>; readonly state: any; stateIn: (...path: (string | number | symbol)[]) => DeepState; deep: (...path: (string | number | symbol)[]) => DeepStorage; root: () => DefaultDeepStorage; readonly props: { [P in keyof State]: DeepStorage; }; prop: (name: Key) => State[Key]; addSubscriber: (subscriber: Subscriber) => void; removeSubscriber: (subscriber: Subscriber) => void; } export declare function parsePath(path: Path | stringNumberOrSymbol): Path; export declare function parsePaths(paths: { [key: string]: Path | stringNumberOrSymbol; }): { [key: string]: Path; }; export declare const deepStorage: (s: State) => DeepStorage;