diff options
author | 2021-12-12 17:48:47 +0100 | |
---|---|---|
committer | 2021-12-12 17:48:47 +0100 | |
commit | fc7e9312d00e60171ed77c477ed91231d3dbfff9 (patch) | |
tree | cc185dd088b5fa6e9357aab3c9062a70626d1953 /language-web/src/main/js/RootStore.tsx | |
parent | build: refactor java-application conventions (diff) | |
download | refinery-fc7e9312d00e60171ed77c477ed91231d3dbfff9.tar.gz refinery-fc7e9312d00e60171ed77c477ed91231d3dbfff9.tar.zst refinery-fc7e9312d00e60171ed77c477ed91231d3dbfff9.zip |
build: move modules into subproject directory
Diffstat (limited to 'language-web/src/main/js/RootStore.tsx')
-rw-r--r-- | language-web/src/main/js/RootStore.tsx | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/language-web/src/main/js/RootStore.tsx b/language-web/src/main/js/RootStore.tsx deleted file mode 100644 index baf0b61e..00000000 --- a/language-web/src/main/js/RootStore.tsx +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | import React, { createContext, useContext } from 'react'; | ||
2 | |||
3 | import { EditorStore } from './editor/EditorStore'; | ||
4 | import { ThemeStore } from './theme/ThemeStore'; | ||
5 | |||
6 | export class RootStore { | ||
7 | editorStore; | ||
8 | |||
9 | themeStore; | ||
10 | |||
11 | constructor(initialValue: string) { | ||
12 | this.themeStore = new ThemeStore(); | ||
13 | this.editorStore = new EditorStore(initialValue, this.themeStore); | ||
14 | } | ||
15 | } | ||
16 | |||
17 | const StoreContext = createContext<RootStore | undefined>(undefined); | ||
18 | |||
19 | export interface RootStoreProviderProps { | ||
20 | children: JSX.Element; | ||
21 | |||
22 | rootStore: RootStore; | ||
23 | } | ||
24 | |||
25 | export function RootStoreProvider({ children, rootStore }: RootStoreProviderProps): JSX.Element { | ||
26 | return ( | ||
27 | <StoreContext.Provider value={rootStore}> | ||
28 | {children} | ||
29 | </StoreContext.Provider> | ||
30 | ); | ||
31 | } | ||
32 | |||
33 | export const useRootStore = (): RootStore => { | ||
34 | const rootStore = useContext(StoreContext); | ||
35 | if (!rootStore) { | ||
36 | throw new Error('useRootStore must be used within RootStoreProvider'); | ||
37 | } | ||
38 | return rootStore; | ||
39 | }; | ||