File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change 33// ancestor components re-render before descendants
44
55function initListeners ( ) {
6- let count = 0
76 let current = [ ]
87 let next = [ ]
98
109 return {
1110 clear ( ) {
12- count = 0
1311 next = null
1412 current = null
1513 } ,
1614
1715 notify ( ) {
1816 current = next
19- for ( let i = 0 ; i < count ; i ++ ) {
17+ for ( let i = 0 ; i < current . length ; i ++ ) {
2018 current [ i ] ( )
2119 }
2220 } ,
@@ -25,15 +23,13 @@ function initListeners() {
2523 let isSubscribed = true
2624 if ( next === current ) next = current . slice ( )
2725 next . push ( listener )
28- count ++
2926
3027 return function unsubscribe ( ) {
31- if ( ! isSubscribed || count === 0 ) return
28+ if ( ! isSubscribed || ! current ) return
3229 isSubscribed = false
3330
3431 if ( next === current ) next = current . slice ( )
3532 next . splice ( next . indexOf ( listener ) , 1 )
36- count --
3733 }
3834 }
3935 }
You can’t perform that action at this time.
0 commit comments