about summary refs log tree commit diff
path: root/src/state/models
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-06-09 13:03:25 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-06-09 13:03:25 -0500
commitd6942bffab68ce80d5cb26b42710dd9276f62ded (patch)
tree309f8d64f95d526d3cae6c00611c93b04f12944e /src/state/models
parent92ca49ab9a309510a5503a4df6a0ebcfba30f918 (diff)
downloadvoidsky-d6942bffab68ce80d5cb26b42710dd9276f62ded.tar.zst
Add state management
Diffstat (limited to 'src/state/models')
-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)