File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
packages/gatsby-cli/src/reporter Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,10 @@ export const StoreStateProvider = ({ children }) => {
8
8
const [ state , setState ] = useState ( getStore ( ) . getState ( ) )
9
9
10
10
useEffect ( ( ) => {
11
- onLogAction ( ( ) => {
11
+ const unsubscribe = onLogAction ( ( ) => {
12
12
setState ( getStore ( ) . getState ( ) )
13
13
} )
14
+ return unsubscribe
14
15
} , [ ] )
15
16
16
17
return (
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ let store = Redux.createStore(
11
11
)
12
12
13
13
const storeSwapListeners = [ ]
14
- const onLogActionListeners = [ ]
14
+ const onLogActionListeners = new Set ( )
15
15
16
16
const isInternalAction = action => {
17
17
if (
@@ -58,15 +58,18 @@ const iface = {
58
58
// deal with actions needed just for internal tracking of status
59
59
return
60
60
}
61
- onLogActionListeners . forEach ( fn => {
61
+ for ( const fn of onLogActionListeners ) {
62
62
fn ( action )
63
- } )
63
+ }
64
64
} ,
65
65
onStoreSwap : fn => {
66
66
storeSwapListeners . push ( fn )
67
67
} ,
68
68
onLogAction : fn => {
69
- onLogActionListeners . push ( fn )
69
+ onLogActionListeners . add ( fn )
70
+ return ( ) => {
71
+ onLogActionListeners . delete ( fn )
72
+ }
70
73
} ,
71
74
setStore : s => {
72
75
s . dispatch ( {
You can’t perform that action at this time.
0 commit comments