Redux is a state container for JavaScript apps. In this talk we discuss some basic ideas of functional programming and how they relate to the three rules of Redux.
of statements. ➤ Control-flow structures may be used to conditionally execute statements or execute statements repeatedly. ➤ As statements are executed, the state of a program changes. ➤ Data may be mutable.
things are not what to do. ➤ If you say a =5 you cannot later say a = 6 because 5 != 6. ➤ You can also declare that the sum of a list of numbers is the first number (head) plus the sum of the remainder (tail) as a function (f(x)). ➤ Functions have no side effects and data is immutable.
result. ➤ Given the same input, a function always produces the same output. ➤ You can prove that a function is correct. ➤ You can string together correct functions to compose solutions to more complex problems.
helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger. You can use Redux together with React, or with any other view library. It is tiny (2kB) and has no dependencies. Source: https://github.com/rackt/redux
the state. ➤ The only way you can get data into or remove data from the application is by dispatching an action. ➤ An action is just a plain javascript object. ➤ An action is the minimal description of how the state should change.
return value is determined by the inputs - it has referential transparency. ➤ The reducer is a pure function. ➤ The reducer takes the previous application state and an action as parameters. ➤ The reducer returns a new application state. ➤ It does not modify the previous application state!
http://redux.js.org/ ➤ Getting Started with Redux with Dan Abramov https://egghead.io/series/getting-started-with-redux ➤ Live editing time travelling goodness https://github.com/gaearon/redux-devtools ➤ ImmutableJS https://facebook.github.io/immutable-js/