@datorama/akita
Version:
State Management Tailored-Made for JS Applications
41 lines (40 loc) • 1.71 kB
TypeScript
import { OperatorFunction } from 'rxjs';
import { MaybeAsync } from './types';
export declare function setSkipStorageUpdate(skip: boolean): void;
export declare function getSkipStorageUpdate(): boolean;
export interface PersistStateStorage {
getItem(key: string): MaybeAsync;
setItem(key: string, value: any): MaybeAsync;
clear(): void;
}
export interface PersistStateParams {
/** The storage key */
key: string;
/** Storage strategy to use. This defaults to LocalStorage but you can pass SessionStorage or anything that implements the StorageEngine API. */
storage: PersistStateStorage;
/** Custom deserializer. Defaults to JSON.parse */
deserialize: Function;
/** Custom serializer, defaults to JSON.stringify */
serialize: Function;
/**
* By default the whole state is saved to storage, use this param to include only the stores you need.
* Pay attention that you can't use both include and exclude
*/
include: (string | ((storeName: string) => boolean))[];
/**
* By default the whole state is saved to storage, use this param to exclude stores that you don't need.
* Pay attention that you can't use both include and exclude
*/
exclude: string[];
preStorageUpdate(storeName: string, state: any): any;
preStoreUpdate(storeName: string, state: any): any;
skipStorageUpdate: () => boolean;
preStorageUpdateOperator: () => OperatorFunction<any, any>;
/** Whether to persist a dynamic store upon destroy */
persistOnDestroy: boolean;
}
export declare function persistState(params?: Partial<PersistStateParams>): {
destroy(): void;
clear(): void;
clearStore(storeName?: string): void;
};