UNPKG

@snipsonian/observable-state

Version:

Observable-state snippets (redux-like)

25 lines (24 loc) 924 B
export interface IStateStorageConfig<State> { local?: IBrowserStorageConfig<State>; session?: IBrowserStorageConfig<State>; custom?: ICustomStorageConfig<State>; } interface IBaseStorageConfig<State> { getStatePartToSave: (state: State) => Partial<State>; } export interface IBrowserStorageConfig<State> extends IBaseStorageConfig<State> { browserStorageKey: string; } export interface ICustomStorageConfig<State> extends IBaseStorageConfig<State> { readFromStorage: () => Partial<State>; saveToStorage: (state: Partial<State>) => void; } export declare function determineInitialState<State>({ initialState, stateStorageConfig, }: { initialState: State; stateStorageConfig: IStateStorageConfig<State>; }): State; export declare function saveStateToStorage<State>({ state, stateStorageConfig, }: { state: State; stateStorageConfig: IStateStorageConfig<State>; }): void; export {};