Genius former colleagues of mine like Scott Corgan would speak from time to time about what I knew must’ve been a simple, yet important distinction. To be honest, despite his excellent, and numerous explanations, it took awhile before I understood what a pure function really was, and more importantly, why it matters.
In Redux, almost all of the moving parts are pure functions. There is one centralized store and source of truth. Reducer functions are responsible for manipulating data that makes up the store. Everything is much clearer than in vanilla Flux.
To be honest, you can really only get so far in learning about Redux without understanding the difference between pure and impure functions. A pure function is defined by the following two requirements:
1. The return values of the function may depend only upon the value of the arguments passed to the function.
2. The function may not have side effects like network or database calls.
That is it. There is nothing else to understand about the difference in definition between a pure and impure function.
Now your side effects, such as API calls, do need to go somewhere, but in a reducer is not that place. This touches on some (only slightly) more advanced uses of Redux and is out of scope for this blog post.
If you have anything to correct and/or add, or would like to suggest other areas of Redux for future blog posts that you are interested in learning about, please feel free to tweet @_kulte or email me at zafriedman at gmail dot com .