UNPKG

reactant-storage

Version:

A persistence storage plugin for Reactant

89 lines 2.79 kB
import { PropsWithChildren, ReactNode } from 'react'; import { PluginModule } from 'reactant-module'; import type { Middleware, Reducer, ReducersMapObject, Store } from 'redux'; import { Storage, PersistConfig, Persistor, REHYDRATE } from 'redux-persist'; declare const StorageOptions: unique symbol; export declare const getRehydrated: (target: object) => undefined | boolean; export interface IStorageOptions extends Partial<PersistConfig<any>> { /** * define storage container */ storage: Storage; /** * define storage loading UI */ loading?: ReactNode; } export type SetStorageOptions<T> = Pick<Partial<PersistConfig<any>>, Exclude<keyof PersistConfig<any>, 'key' | 'blacklist' | 'whitelist'>> & { /** * define persistent data blacklist */ blacklist?: (keyof T)[]; /** * define persistent data whitelist */ whitelist?: (keyof T)[]; }; declare class ReactantStorage extends PluginModule { protected blacklist: string[]; protected persistor?: Persistor; /** * all modules rehydrated */ rehydrated: boolean; constructor(options: IStorageOptions); protected persistConfig: Record<string, PersistConfig<any>>; protected persistRootConfig: Pick<IStorageOptions, Exclude<keyof IStorageOptions, 'key'>> & { key: string; }; options: IStorageOptions; storageSettingMap: Map<object, Function>; /** * set module to storage persistent */ setStorage<T extends object>(target: T, options: SetStorageOptions<T>): void; middleware: Middleware; /** * get every module rehydrated */ getRehydrated(target: object): boolean | undefined; beforeCombinePersistReducer?: () => void; beforeCombineRootReducers(reducers: ReducersMapObject): ReducersMapObject; afterCombineRootReducers(rootReducer: Reducer): any; get store(): Service; /** * manual persist */ manualPersist: boolean; /** * persistence paused */ paused: boolean; afterCreateStore(store: Store): Store; private _enhancePersistor; /** * pauses persistence until persist() is called */ pause(): any; /** * resumes persistence */ persist(): any; /** * immediately writes all pending state to disk and returns a promise */ flush(): any; /** * purges state from disk and returns a promise */ purge(): any; protected rehydrateCallbackSet: Set<() => void>; protected _onRehydrated(): void; /** * callback when rehydrated */ onRehydrated(callback: () => void): void; provider: (props: PropsWithChildren<{}>) => JSX.Element; } export { ReactantStorage as Storage, StorageOptions, REHYDRATE }; //# sourceMappingURL=storage.d.ts.map