Is there any way to find out how can I get the difference between previous and current state in ngrx.
This would be really helpful, thanks in advance.
I personally use a select, like
let state = store.select(['reducer', 'state']);
and subscribe to the state change
state.takeLast(2).subscribe((result: any[]) => {
for (let x of result) {
if (result[x - 1] && (result[x] someCondition result[x - 1])){
doSomething
}
}
})
then just do your simple conditional stuff and viola!
rxjs operators are plentiful and are awesome (like last() or takeLast() for instance)
EDIT just noticed the question and title are a bit different. But you can basically if you dispatch to a state that is used for different actions, the pub/sub method above will still work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With