aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/RootStore.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-10-07 19:44:41 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-05 19:41:14 +0100
commitabe176d0888c0fdcc803ddafe71a5cee9f4b63a0 (patch)
treeea7d5722c8e981ba540e648fbacbfd0e4a55768a /subprojects/frontend/src/RootStore.ts
parentfix: test and lint failures (diff)
downloadrefinery-abe176d0888c0fdcc803ddafe71a5cee9f4b63a0.tar.gz
refinery-abe176d0888c0fdcc803ddafe71a5cee9f4b63a0.tar.zst
refinery-abe176d0888c0fdcc803ddafe71a5cee9f4b63a0.zip
refactor(frontend): improve HMR experience
Use a HMR acceptor as in https://github.com/vitejs/vite/issues/10227#issuecomment-1256969751 Also updates frontend tooling to the latest version (yarn now support typescript 4.8.4)
Diffstat (limited to 'subprojects/frontend/src/RootStore.ts')
-rw-r--r--subprojects/frontend/src/RootStore.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/subprojects/frontend/src/RootStore.ts b/subprojects/frontend/src/RootStore.ts
new file mode 100644
index 00000000..54a80501
--- /dev/null
+++ b/subprojects/frontend/src/RootStore.ts
@@ -0,0 +1,47 @@
1import { getLogger } from 'loglevel';
2import { makeAutoObservable, runInAction } from 'mobx';
3
4import PWAStore from './PWAStore';
5import type EditorStore from './editor/EditorStore';
6import ThemeStore from './theme/ThemeStore';
7
8const log = getLogger('RootStore');
9
10export default class RootStore {
11 editorStore: EditorStore | undefined;
12
13 readonly pwaStore: PWAStore;
14
15 readonly themeStore: ThemeStore;
16
17 disposed = false;
18
19 constructor(initialValue: string) {
20 this.pwaStore = new PWAStore();
21 this.themeStore = new ThemeStore();
22 makeAutoObservable(this, {
23 pwaStore: false,
24 themeStore: false,
25 });
26 import('./editor/EditorStore')
27 .then(({ default: EditorStore }) => {
28 runInAction(() => {
29 if (this.disposed) {
30 return;
31 }
32 this.editorStore = new EditorStore(initialValue, this.pwaStore);
33 });
34 })
35 .catch((error) => {
36 log.error('Failed to load EditorStore', error);
37 });
38 }
39
40 dispose(): void {
41 if (this.disposed) {
42 return;
43 }
44 this.editorStore?.dispose();
45 this.disposed = true;
46 }
47}