I want to do something based on an action being dispatched, rather than the state being a given value. For example:
- Reload the timeline immediately after I log in on my Twitter client
- Retrieve data about a notification immediately on receiving a notification
I could set up a reactive signal or promise or something like that and pump events into it, and dispatch events into Redux. But I already have a place that I'm dispatching actions into: the Redux store.
It reminds me of Yaron Minsky's blog post with some discussion about edge-triggering vs level-triggering.
(waitForState
is a bit overengineered for this example, compared to waitForAction
)
Or, with a subscriber: