about summary refs log tree commit diff
path: root/src/state/models/root-store.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/models/root-store.ts')
-rw-r--r--src/state/models/root-store.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/state/models/root-store.ts b/src/state/models/root-store.ts
new file mode 100644
index 000000000..164dfcced
--- /dev/null
+++ b/src/state/models/root-store.ts
@@ -0,0 +1,16 @@
+/**
+ * The root store is the base of all modeled state.
+ */
+
+import {Instance, SnapshotOut, types} from 'mobx-state-tree'
+import {createContext, useContext} from 'react'
+
+export const RootStoreModel = types.model('RootStore').props({})
+
+export interface RootStore extends Instance<typeof RootStoreModel> {}
+export interface RootStoreSnapshot extends SnapshotOut<typeof RootStoreModel> {}
+
+// react context & hook utilities
+const RootStoreContext = createContext<RootStore>({} as RootStore)
+export const RootStoreProvider = RootStoreContext.Provider
+export const useStores = () => useContext(RootStoreContext)