File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default function createDevToolsStore(onDispatch) {
66 skippedActions : { } ,
77 currentStateIndex : 0
88 } ;
9- let listeners = [ ] ;
9+ let handleChangeState = null ;
1010 let initiated = false ;
1111
1212 function dispatch ( action ) {
@@ -24,23 +24,21 @@ export default function createDevToolsStore(onDispatch) {
2424
2525 function setState ( state ) {
2626 currentState = state ;
27- listeners . forEach ( listener => listener ( ) ) ;
28- initiated = true ;
27+ if ( handleChangeState ) handleChangeState ( ) ;
28+ if ( ! initiated ) initiated = true ;
2929 }
3030
3131 function subscribe ( listener ) {
32- listeners . push ( listener ) ;
32+ handleChangeState = listener ;
3333
3434 return function unsubscribe ( ) {
35- const index = listeners . indexOf ( listener ) ;
36- listeners . splice ( index , 1 ) ;
35+ handleChangeState = null ;
3736 } ;
3837 }
3938
4039 return {
4140 dispatch,
4241 getState,
43- subscribe,
4442 liftedStore : {
4543 dispatch,
4644 getState,
You can’t perform that action at this time.
0 commit comments