RFC: Removing the store.dispatch provided to epics
See original GitHub issueHey all, when we originally made redux-observable we thought it would be a good idea to keep the ability to imperatively call store.dispatch
inside your epics as basically a rarely used (if ever) escape hatch to just “get things done”. While it would be nice to have it just in case, I’m quite concerned with the number of new people I come across who use it extensively and even exclusively, rather than emitting actions. I even see calls inside map
and I feel like it’s our fault for giving people the gun to shoot themselves with. I see this in stackoverflow, gitter, and even youtube tutorials on how to use redux-observable. 😢
Sooo. I’m proposing we remove it entirely from epics. I’m not sure what that means for the function signature of epics but I imagine it would change since the second argument object would only have getState now and that’s just weird. If we generally have consensus to remove dispatch, having it as part of the store enhancer effort since that will provide a cleaner migration/deprecation path for people. If that’s the case, both of these and a few other minor things would probably be part of us finally starting to move towards a 1.0. Starting with 1.0.0-alpha release first, then beta, etc.
Thoughts? I’m definitely willing to hear out people’s arguments for keeping it.
Cc/ @BerkeleyTrue @rgbkrk
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
merge
andof
are your friends here. You can emit the one action along with the other stream of actionsApologies to Jay for answering it here instead of SO, just for the sake of having a canonical (?) answer here while an SO post is hopefully created. Note: I matched the style above, this is how I’d really handle it:
I think It was a good feature… or am I one of those shooters??
https://stackoverflow.com/questions/48931708/whats-the-proper-way-to-dispatch-action-inside-epic