- Mastering Immutable.js
- Adam Boduch
- 201字
- 2021-07-08 10:30:04
Data is only created
Let's revisit the visualization of data flowing from top to bottom, ending with a side-effect. Along the way, we're either changing the state of data with persistent changes, or we're shaping the data that we need using sequence transformations. From the beginning to the end of this flow, we're only creating new data.
The chained Immutable.js collection method calls result in new data—every time. This means that if we make a mistake and accidentally try to use data in a way that falls outside of the unidirectional flow that we're following, Immutable.js will protect us from ourselves. When this happens, the result is often a broken application that doesn't work. This is better than a half-working application that has mutability bugs hidden deep inside of it.
For example, suppose that we call set() on an immutable map to set a value, expecting that simply calling this method would be enough to change the state of the map. But since the set() method is a persistent change, it doesn't change the map—it creates and returns a new map. So while we weren't expecting this behavior, it's better than accidentally changing the state of something.
- Java入門經(jīng)典(第6版)
- Java 9 Programming Blueprints
- Learning Firefox OS Application Development
- Visual C++數(shù)字圖像處理技術(shù)詳解
- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- 低代碼平臺開發(fā)實(shí)踐:基于React
- Visual C++開發(fā)入行真功夫
- Node.js:來一打 C++ 擴(kuò)展
- Learning Material Design
- 零基礎(chǔ)學(xué)C語言第2版
- JSP程序設(shè)計(jì)與案例實(shí)戰(zhàn)(慕課版)
- 從零開始構(gòu)建深度前饋神經(jīng)網(wǎng)絡(luò):Python+TensorFlow 2.x
- Python機(jī)器學(xué)習(xí)
- Getting Started with Hazelcast
- Expert Angular