1 | import React from "react";
|
2 | import { ProviderProps } from ".";
|
3 | import { Action, Reducer } from "./types";
|
4 | export interface Store<S> {
|
5 | useState(): S;
|
6 | useDispatch(): (action: Action<S>, callback?: () => void) => void;
|
7 | persist(state: S, action: {
|
8 | type: any;
|
9 | }): void;
|
10 | setToState(): Promise<void>;
|
11 | dispatch: (action: any, callback?: () => void) => void;
|
12 | state: S;
|
13 | Provider: (props: Omit<ProviderProps<any>, "store">) => any;
|
14 | }
|
15 | export interface PrivateStore<S> extends Store<S> {
|
16 | stateContext: React.Context<S>;
|
17 | dispatchContext: React.Context<(action: any, callback?: () => void) => void>;
|
18 | reducer: Reducer<S>;
|
19 | initialState: S;
|
20 | persistKey?: string;
|
21 | }
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export declare const createStore: <T extends {
|
27 | [x: string]: any;
|
28 | }>({ reducer, initialState, mapStateToPersist, storage, persistKey, }: {
|
29 | reducer: Reducer<T, {
|
30 | type: any;
|
31 | payload: T;
|
32 | }>;
|
33 | initialState: T;
|
34 |
|
35 | storage?: any;
|
36 | persistKey?: string | undefined;
|
37 | mapStateToPersist?: ((state: T) => Partial<T>) | undefined;
|
38 | }) => Store<T>;
|
39 |
|
\ | No newline at end of file |