vuex-state-storage-sync
Version:
Synchronization of vuex state and storage
48 lines (44 loc) โข 1.9 kB
text/typescript
import { MutationPayload, Store } from 'vuex';
/*****************************************************************
* VUEX-STATE-STORAGE-SYNC - Minimal Persist/Synchronize State Plugin for Vuex
* (c) 2024-present AGUMON (https://github.com/ljlm0402/vuex-state-storage-sync)
*
* This source code is licensed under the MIT license.
* See the LICENSE file in the project root for more information.
*
* Made with โค๏ธ by AGUMON ๐ฆ
*****************************************************************/
/**
* Storage ์ธํฐํ์ด์ค ์ ์
* removeItem์ optional๋ก ๋์ด ๋ค์ํ storage ์์ง์ ์ง์
*/
interface Storage {
getItem: (key: string) => string | null;
setItem: (key: string, value: string) => void;
removeItem?: (key: string) => void;
}
type ArrayMergeFn = (storeArr: any[], savedArr: any[]) => any[];
interface Options<State> {
key?: string;
storage?: Storage;
paths?: string[];
overwrite?: boolean;
fetchBeforeUse?: boolean;
getState?: (key: string, storage: Storage) => any;
setState?: (key: string, state: any, storage: Storage) => void;
removeState?: (key: string, storage: Storage) => void;
reducer?: (state: State, paths?: string[]) => object;
filter?: (mutation: MutationPayload) => boolean;
merge?: (obj1: object | any[], obj2: object | any[], options: object) => object | any[];
arrayMerge?: ArrayMergeFn;
arrayMerger?: ArrayMergeFn;
rehydrated?: (store: Store<State>) => void;
subscriber?: (store: Store<State>) => (handler: (mutation: any, state: State) => void) => void;
assertStorage?: (storage: Storage) => void | Error;
}
/**
* vuex-state-storage-sync ํ๋ฌ๊ทธ์ธ ๋ฉ์ธ ํจ์
* @param options ์ฌ์ฉ์ ์ง์ ์ต์
*/
declare function export_default<State extends object = any>(options?: Options<State>): (store: Store<State>) => void;
export { export_default as default };