Redux

Managing the state of an application can be hard, especially if the application is bigger. For example if there is a list on a website, which gets modified with JavaScript in different places, it's hard to tell in which state that list is currently in. It can be assumed which items it currently holds, or even be looked up in the DOM. But this system can be messed up pretty quickly, if it's necassary to look through the DOM to find out in which state the application is currently in. Of course it's possible to modify the list without looking the state up, but then it often results in two functions having a different state. Redux tries to solve that.

Single Source of Truth

In Redux there is one global object which describes the current state the application is in. If the state should be changed, an action is dispatched. This action gets passed inside a reducer, which reads the necessary data out of it and merges it with the current global state. After the global state has changed, all components update reactively. It's not possible to change the global state directly.

This way the data flow is uni-directional. This means that all data in an application follows the same life-cycle pattern, making the logic more predictable and easier to understand.

results matching ""

    No results matching ""