官术网_书友最值得收藏!

What other direction is there?

The best way to visualize unidirectional data flow is in a top-down fashion. Data starts in one state at the top, changes state as it flows downward, ending with a side-effect that does something with the data. When this is enforced as a property of the architecture, side-effects are predictable. We can easily trace the starting point of data, through the transformations it makes, ending with the visible side-effect.

When we don't enforce a unidirectional data flow, it's difficult to trace cause and effect. This is the main reason that Facebook started promoting the concept with the creation of Flux—to prevent components from changing state at will and passing the changed state on to another component. For example, let's say that you aren't using immutable data, and that one component changes its state in response to an event. Then some other component that references this state renders itself, causing its state to change as a result of the first change. These are nothing more than uncontrolled side-effects.

Immutable.js is a low-level library compared to the ideas of Flux or a UI component library such as React. Even if you're not using either of these, you can still leverage Immutable.js to build a unidirectional architecture.

主站蜘蛛池模板: 辽中县| 页游| 龙游县| 清丰县| 洞头县| 尼勒克县| 留坝县| 平江县| 清镇市| 扎鲁特旗| 万载县| 临潭县| 庆安县| 揭东县| 科尔| 灌南县| 岳池县| 赤壁市| 观塘区| 五台县| 静乐县| 新竹县| 衡水市| 固安县| 尼玛县| 杭锦旗| 司法| 延安市| 辰溪县| 黄浦区| 张掖市| 潜江市| 奉贤区| 台前县| 青铜峡市| 万盛区| 酉阳| 松滋市| 敖汉旗| 柘荣县| 武汉市|