Skip to content

Commit 58a4b27

Browse files
authored
Simplify, pretty up, and remove vars
1 parent 2f57bcc commit 58a4b27

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/utils/Subscription.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ import { getBatch } from './batch'
77
const nullListeners = { notify() {} }
88

99
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
1313

14-
var current = {}
15-
var id = 0
1614
return {
1715
clear() {
18-
current = {}
16+
listeners = {}
1917
},
18+
2019
notify() {
21-
var listeners = current
2220
batch(() => {
2321
for (const id in listeners) {
2422
listeners[id]()
@@ -27,14 +25,15 @@ function createListenerCollection() {
2725
},
2826

2927
get() {
30-
return current
28+
return listeners
3129
},
3230

3331
subscribe(listener) {
34-
var currentId = id++
35-
current[currentId] = listener
32+
const currentId = id++
33+
listeners[currentId] = listener
34+
3635
return function unsubscribe() {
37-
delete current[currentId]
36+
delete listeners[currentId]
3837
}
3938
}
4039
}

0 commit comments

Comments
 (0)