August 2017
Beginner
374 pages
10h 41m
English
To subscribe to changes in the store, we simply call store.subscribe() with a function that will be executed when the store changes. For example, we could log every state change:
const unsubscribe = store.subscribe(() => { console.log('state changed:', store.getState())})
You might have noted that this code does not produce any output yet. The initialization process of the Redux store does not trigger a call to our subscribed function. We first need to dispatch an action to see the state change being logged.
Read now
Unlock full access