@@ -10,6 +10,7 @@ window.devToolsExtension = function(config = {}) {
1010 let shouldInit = true ;
1111 let lastAction ;
1212 let errorOccurred = false ;
13+ let isMonitored = false ;
1314
1415 function stringify ( obj ) {
1516 return jsan . stringify ( obj , function ( key , value ) {
@@ -65,6 +66,11 @@ window.devToolsExtension = function(config = {}) {
6566 store . liftedStore . dispatch ( message . payload ) ;
6667 } else if ( message . type === 'UPDATE' ) {
6768 relay ( 'STATE' , store . liftedStore . getState ( ) ) ;
69+ } else if ( message . type === 'START' ) {
70+ isMonitored = true ;
71+ relay ( 'STATE' , store . liftedStore . getState ( ) ) ;
72+ } else if ( message . type === 'STOP' ) {
73+ isMonitored = false ;
6874 }
6975 }
7076
@@ -110,14 +116,15 @@ window.devToolsExtension = function(config = {}) {
110116
111117 // Detect when the tab is reactivated
112118 document . addEventListener ( 'visibilitychange' , function ( ) {
113- if ( document . visibilityState === 'visible' ) {
119+ if ( document . visibilityState === 'visible' && isMonitored ) {
114120 shouldInit = true ;
115121 relay ( 'STATE' , store . liftedStore . getState ( ) ) ;
116122 }
117123 } , false ) ;
118124 }
119125
120126 function monitorReducer ( state = { } , action ) {
127+ if ( ! isMonitored ) return state ;
121128 lastAction = action . type ;
122129 if ( lastAction === '@@redux/INIT' && store . liftedStore ) {
123130 // Send new lifted state on hot-reloading
@@ -129,6 +136,7 @@ window.devToolsExtension = function(config = {}) {
129136 }
130137
131138 function handleChange ( state , liftedState ) {
139+ if ( ! isMonitored ) return ;
132140 const nextActionId = liftedState . nextActionId ;
133141 const liftedAction = liftedState . actionsById [ nextActionId - 1 ] ;
134142 const action = liftedAction . action ;
0 commit comments