vuex-state-storage-sync
Version:
Synchronization of vuex state and storage
23 lines (22 loc) • 971 B
TypeScript
import { Store, MutationPayload } from 'vuex';
interface Storage {
getItem: (key: string) => any;
setItem: (key: string, value: any) => void;
}
interface Options<State> {
storage?: Storage;
key?: string;
paths?: string[];
overwrite?: boolean;
fetchBeforeUse?: boolean;
getState?: (key: string, storage: Storage) => any;
setState?: (key: string, state: any, storage: Storage) => void;
reducer?: (state: State, paths: string[]) => object;
filter?: (mutation: MutationPayload) => boolean;
merge?: (object1: Object | Array<any>, object2: Object | Array<any>, options: Object) => object | Array<any>;
arrayMerge?: (state: any[], saved: any[]) => any;
rehydrated?: (store: Store<State>) => void;
subscriber?: (store: Store<State>) => (handler: (mutation: any, state: State) => void) => void;
}
export default function <State>(options?: Options<State>): (store: Store<State>) => void;
export {};