Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 714c1ae

Browse files
committed
cleanup the init store
1 parent abc60b1 commit 714c1ae

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

stores/index.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*
44
*/
55

6+
// import { getSnapshot, applySnapshot } from 'mobx-state-tree'
7+
68
import AppStore from './AppStore'
79

810
let appStore = null
@@ -12,25 +14,25 @@ const createRootStore = (isServer, langSetup) => {
1214
}
1315

1416
export function initAppStore(isServer = false, langSetup) {
15-
let ret
16-
17-
if (isServer) {
18-
if (appStore === null) {
19-
ret = createRootStore(isServer, langSetup)
20-
} else {
21-
ret = appStore
22-
}
23-
} else {
24-
if (appStore === null) {
25-
appStore = createRootStore(isServer, langSetup)
26-
}
27-
ret = appStore
17+
if (appStore === null) {
18+
appStore = createRootStore(isServer, langSetup)
2819
}
29-
return ret
30-
}
31-
32-
export function getStoreInstance() {
3320
return appStore
3421
}
3522

23+
export const other = false
3624
// export default initAppStore
25+
26+
/*
27+
if (module.hot) {
28+
if (module.hot.data && module.hot.data.appStore) {
29+
console.log('applySnapshot appStore: ', appStore)
30+
console.log('applySnapshot: ', module.hot.data.appStore)
31+
// applySnapshot(appStore, module.hot.data.appStore)
32+
}
33+
module.hot.dispose(data => {
34+
console.log('dispose: data: ', getSnapshot(appStore))
35+
data.appStore = getSnapshot(appStore)
36+
})
37+
}
38+
*/

0 commit comments

Comments
 (0)