diff options
Diffstat (limited to 'subprojects/frontend/src/RootStore.tsx')
-rw-r--r-- | subprojects/frontend/src/RootStore.tsx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/subprojects/frontend/src/RootStore.tsx b/subprojects/frontend/src/RootStore.tsx index 4a267b0e..e08dd750 100644 --- a/subprojects/frontend/src/RootStore.tsx +++ b/subprojects/frontend/src/RootStore.tsx | |||
@@ -1,16 +1,31 @@ | |||
1 | import { getLogger } from 'loglevel'; | ||
2 | import { makeObservable, observable, runInAction } from 'mobx'; | ||
1 | import React, { createContext, useContext } from 'react'; | 3 | import React, { createContext, useContext } from 'react'; |
2 | 4 | ||
3 | import EditorStore from './editor/EditorStore'; | 5 | import type EditorStore from './editor/EditorStore'; |
4 | import ThemeStore from './theme/ThemeStore'; | 6 | import ThemeStore from './theme/ThemeStore'; |
5 | 7 | ||
8 | const log = getLogger('RootStore'); | ||
9 | |||
6 | export default class RootStore { | 10 | export default class RootStore { |
7 | readonly editorStore: EditorStore; | 11 | editorStore: EditorStore | undefined; |
8 | 12 | ||
9 | readonly themeStore: ThemeStore; | 13 | readonly themeStore: ThemeStore; |
10 | 14 | ||
11 | constructor(initialValue: string) { | 15 | constructor(initialValue: string) { |
12 | this.editorStore = new EditorStore(initialValue); | ||
13 | this.themeStore = new ThemeStore(); | 16 | this.themeStore = new ThemeStore(); |
17 | makeObservable(this, { | ||
18 | editorStore: observable, | ||
19 | }); | ||
20 | import('./editor/EditorStore') | ||
21 | .then(({ default: EditorStore }) => { | ||
22 | runInAction(() => { | ||
23 | this.editorStore = new EditorStore(initialValue); | ||
24 | }); | ||
25 | }) | ||
26 | .catch((error) => { | ||
27 | log.error('Failed to load EditorStore', error); | ||
28 | }); | ||
14 | } | 29 | } |
15 | } | 30 | } |
16 | 31 | ||