store.ts 682 B

1234567891011121314151617181920212223242526
  1. import { createStore, createTypedHooks } from "easy-peasy";
  2. import { auth, Auth } from "./auth";
  3. import { loading, Loading } from "./loading";
  4. import { settings, Settings } from "./settings";
  5. export interface StoreModel {
  6. auth: Auth;
  7. loading: Loading;
  8. settings: Settings;
  9. }
  10. export const store: StoreModel = {
  11. auth,
  12. loading,
  13. settings
  14. };
  15. const typedHooks = createTypedHooks<StoreModel>();
  16. export const useStoreActions = typedHooks.useStoreActions;
  17. export const useStoreDispatch = typedHooks.useStoreDispatch;
  18. export const useStoreState = typedHooks.useStoreState;
  19. export const initializeStore = (initialState?: StoreModel) =>
  20. createStore(store, { initialState });