blob: 54765621e4cd5b53ec71088acacead8d7879bf75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { Action, createStore, createTypedHooks, action } from "easy-peasy";
import { settings, Settings } from "./settings";
import { loading, Loading } from "./loading";
import { links, Links } from "./links";
import { auth, Auth } from "./auth";
export interface StoreModel {
auth: Auth;
links: Links;
loading: Loading;
settings: Settings;
reset: Action<StoreModel>;
}
let initState: any = {};
export const store: StoreModel = {
auth,
links,
loading,
settings,
reset: action(() => initState)
};
const typedHooks = createTypedHooks<StoreModel>();
export const useStoreActions = typedHooks.useStoreActions;
export const useStoreDispatch = typedHooks.useStoreDispatch;
export const useStoreState = typedHooks.useStoreState;
export const initializeStore = (initialState?: StoreModel) => {
initState = initialState;
return createStore(store, { initialState });
};
|