Ilja
Ilja

Reputation: 46547

Simple way to check if redux state changed

I have a story reducer with state that constantly changes based on actions that users perform, I'd like to show "Save changes" indicator when story gets changed and the only way I can think about to do this is to attach something to each action that changes state to know if it was performed hence affected state of the story. However, I have a lot of these and it would be better if there was a simple way to check if redux state changed and show "Save changes" indicator based on that.

Upvotes: 4

Views: 15699

Answers (2)

ksliu25
ksliu25

Reputation: 134

Why not try a logger?

https://github.com/fcomb/redux-logger

I've found it immensely helpful in debugging anything in my stores by checking the state after each action.

Upvotes: 2

JMM
JMM

Reputation: 26837

It sounds like maybe you just want to subscribe to dispatches on the store and check if state has actually changed from the last time and show your indicator based on that.

Upvotes: 8

Related Questions