Closed
Description
I want to update my view in listener:
store.subscribe(() => {
updateView(store.getState()); // Some DOM api calls.
});
But if it possible to get last action what triggered state change, i can do some think like this:
store.subscribe(() => {
switch (action.type) {
case UPDATE_TITLE:
updateTitle(store.getState().some.title); // Optimize rendering of view. Only one DOM api call.
break;
default:
updateView(store.getState()); // Some DOM api calls.
}
});
Is it possible to get action and state in store.subscribe?