-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathglobal.ts
45 lines (40 loc) · 970 Bytes
/
global.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const State = {}
const mutableState = {}
const Actions = {}
const AsyncState = {}
const Middlewares = {}
// Communicate between Provider-Consumer and Hooks
const Setter: Setter = {
// classSetter stores the setState from Provider
// Invoke the classSetter.setState can update the state of Global Provider.
classSetter: undefined,
// functionSetter stores the setState returned by useStore.
// These setStates can invoke the rerender of hooks components.
functionSetter: {}
}
const Context = {
__global: {}
}
const subscriptions = {}
let devTools: any
let withDevTools = false
let uid = 0 // The unique id of hooks
let storeId = 0 // The unique id of stores
let currentStoreId = '0' // Used for useModel
let gid = 0 // The unique id of models' group
export default {
Actions,
AsyncState,
Context,
Middlewares,
Setter,
State,
devTools,
subscriptions,
mutableState,
gid,
uid,
storeId,
currentStoreId,
withDevTools
} as Global