-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGlobalStore.ts
30 lines (26 loc) · 1014 Bytes
/
GlobalStore.ts
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
import { ToastGlobalStore } from './toast/ToastGlobalStore';
import { configure } from 'mobx';
import environment from 'environment';
import { enableStaticRendering } from 'mobx-react-lite';
import { AuthGlobalStore } from './auth/AuthGlobalStore';
enableStaticRendering(environment.isServer);
// https://mobx.js.org/configuration.html#configuration-
configure({
enforceActions: 'always',
computedRequiresReaction: environment.isBrowser,
reactionRequiresObservable: environment.isBrowser,
observableRequiresReaction: environment.isBrowser,
disableErrorBoundaries: environment.isBrowser,
});
export default class GlobalStore {
readonly authStore: AuthGlobalStore;
readonly toastStore: ToastGlobalStore;
constructor() {
this.authStore = new AuthGlobalStore(this);
this.toastStore = new ToastGlobalStore(this);
}
async hydrate(initialState?: Partial<GlobalStore>) {
// TODO: hydrate your global stores when needed
// this.exampleStore.hydrate(initialState.exampleStore);
}
}