5 ms·
Not to nitpick, because I believe I understand what you mean – but one of the things that bugs me about Redux is that a reducer absolutely CAN have side-effects
by kevincennis 9y ago
Not to nitpick, because I believe I understand what you mean – but one of the things that bugs me about Redux is that a reducer absolutely CAN have side-effects. They're just "not supposed to".
So all it takes is one mistake or one new developer or whatever and suddenly all your assumptions break.
- doque 9y agoIt's one of the essentials principles of redux [1] that reducers must be pure functions without side effects. If you violate that principle, then yes, your assumptions break. That's why you should keep it in mind. You can't really blame the framework if you purposely go against its basic rules. [1] http://redux.js.org/docs/introduction/ThreePrinciples.html#changes-are-made-with-pure-functions http://redux.js.org/docs/introduction/ThreePrinciples.html#c...
- kevincennis 9y agoI get it. I really do. I just wish they had a reasonable way to _enforce_ those rules (though I understand it's not really possible) – or at least make people really go out of their way to break convention.
- acemarke 9y agoYep - I pointed this out in my post "The Tao of Redux, Part 1 - Implementation and Intent": http://blog.isquaredsoftware.com/2017/05/idiomatic-redux-tao-of-redux-part-1/ http://blog.isquaredsoftware.com/2017/05/idiomatic-redux-tao.... Those "Three Principles" are statements of intent, but not literal technical limitations.