top | item 11506479

(no title)

delluminatus | 10 years ago

Redux tries to enforce a convention that all application state is stored in a single object (the "store") and modified using a single pure function (the "reducer"). These conventions make it easier to reason about the application's current state.

Applications behave consistently because all state is stored in a single object, so it can't be desynchronized across components. Because all updates use a single function, it becomes easy to track and respond to any state changes by applying middlewares to that function. Things are more testable because all state is available for stubbing, and because the "reducer" is a testable, pure function typically composed of many other smaller, testable pure functions.

Things like time travel become possible because of the purity of the reducing function. Since it's pure, it can't modify the old state object (technically, it can, but it's against the rules). So in theory, we can undo any state change simply by loading the old state object from where it's being stored by some kind of history middleware.

discuss

order

No comments yet.