File tree 1 file changed +10
-11
lines changed
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,16 @@ import { getBatch } from './batch'
7
7
const nullListeners = { notify ( ) { } }
8
8
9
9
function createListenerCollection ( ) {
10
- var batch = getBatch ( )
11
- // the current/next pattern is copied from redux's createStore code.
12
- // TODO: refactor+expose that code to be reusable here?
10
+ const batch = getBatch ( )
11
+ let listeners = { }
12
+ let id = 0
13
13
14
- var current = { }
15
- var id = 0
16
14
return {
17
15
clear ( ) {
18
- current = { }
16
+ listeners = { }
19
17
} ,
18
+
20
19
notify ( ) {
21
- var listeners = current
22
20
batch ( ( ) => {
23
21
for ( const id in listeners ) {
24
22
listeners [ id ] ( )
@@ -27,14 +25,15 @@ function createListenerCollection() {
27
25
} ,
28
26
29
27
get ( ) {
30
- return current
28
+ return listeners
31
29
} ,
32
30
33
31
subscribe ( listener ) {
34
- var currentId = id ++
35
- current [ currentId ] = listener
32
+ const currentId = id ++
33
+ listeners [ currentId ] = listener
34
+
36
35
return function unsubscribe ( ) {
37
- delete current [ currentId ]
36
+ delete listeners [ currentId ]
38
37
}
39
38
}
40
39
}
You can’t perform that action at this time.
0 commit comments