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

  • Mastering Immutable.js
  • Adam Boduch
  • 176字
  • 2021-07-08 10:30:04

Chaining method calls

Immutable data doesn't just sit inside of a constant. Somehow, your applications need to make use of this data. These are called side-effects. A side-effect is something that is effected by immutable data, such as rendering data on the screen in a user interface or writing data to a file. By contrast, operations performed on immutable collections are either persistent changes or sequence transformations, both of which result in new collections. These operations don't have any side-effects; they just result in new data being created. Another term used for functions that don't cause side-effects is pure functions.

With Immutable.js, you start with a collection of immutable data and work your way toward some sort of side-effect. In functional programming, it's generally best to avoid side-effects due to the problems they cause. But side-effects are unavoidable. Without them, your software cannot interact with its environment. By chaining together Immutable.js collection methods, you can write clean and concise code that transforms immutable data into something that you need—something that a side-effect can use.

主站蜘蛛池模板: 宝丰县| 乌兰浩特市| 南宫市| 丰都县| 麻江县| 盘锦市| 淮安市| 宁夏| 文成县| 宜良县| 石河子市| 治县。| 襄垣县| 兴化市| 黄平县| 乐平市| 赤水市| 宁乡县| 濮阳市| 嵊泗县| 阳曲县| 绥德县| 商都县| 万安县| 夹江县| 临夏县| 贵溪市| 嘉义县| 鄂托克前旗| 大庆市| 凤凰县| 乡宁县| 沂水县| 正镶白旗| 中江县| 科技| 托克逊县| 肇庆市| 甘肃省| 宣威市| 泊头市|