UNPKG

1.12 kBTypeScriptView Raw
1/// <reference types="react" />
2import { Reducer } from "./types";
3export interface Store<S> {
4 useState(nextObserveState?: (keyof S)[]): S;
5 useDispatch(): (action: any, callback?: () => void) => void;
6 persist(state: S, action: {
7 type: any;
8 }): void;
9 setToState(): Promise<void>;
10 dispatch: (action: any, callback?: () => void) => void;
11 state: S;
12}
13export interface PrivateStore<S> extends Store<S> {
14 stateContext: React.Context<S>;
15 dispatchContext: React.Context<(action: any, callback?: () => void) => void>;
16 reducer: Reducer<S>;
17 initialState: S;
18 persistKey: string;
19}
20/**
21 * This function give you an store, use that in your components which want to
22 * connect to store and provider
23 */
24export declare const createStore: <T extends {
25 [x: string]: any;
26}>({ reducer, initialState, mapStateToPersist, storage, persistKey, }: {
27 reducer: Reducer<T, import("./types").Action<T>>;
28 initialState: T;
29 storage: any;
30 persistKey: string;
31 mapStateToPersist?: ((state: T) => Partial<T>) | undefined;
32}) => Store<T>;
33//# sourceMappingURL=createStore.d.ts.map
\No newline at end of file