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

  • Mastering Immutable.js
  • Adam Boduch
  • 180字
  • 2021-07-08 10:30:03

Collection methods return new data

Let's say that you have an Immutable.js collection: coll1. Then, you call a method to insert a new value into the collection: push('newValue'). This is what a persistent change looks like: coll1 persists and push() returns a new collection that includes the new value.

Not all collection methods are mutative. For example, if you want to filter a collection so that only items that pass a given criteria are returned, you would call the filter() method. This would result in a new collection, just like adding a new item would result in a new collection. The difference is that filter() isn't a persistent change—it's part of a sequence transformation.

Think of a sequence transformation as an Instagram filter. You have the original collection: the picture. Then, you have a filter() transformation, which takes the original picture data and rearranges some of the pixel data. You want to be able to see the results of the filter, but you don't want to change the original. The filter is just a view of the original.

主站蜘蛛池模板: 集安市| 依兰县| 板桥市| 洛阳市| 惠水县| 泗水县| 天津市| 永兴县| 沙田区| 洞口县| 万山特区| 黎城县| 内乡县| 富平县| 彩票| 文成县| 潜江市| 海淀区| 新巴尔虎右旗| 昭觉县| 昌都县| 富裕县| 顺义区| 邯郸市| 屏边| 手游| 镇康县| 邻水| 资源县| 从化市| 崇礼县| 黄龙县| 建始县| 游戏| 宝鸡市| 霸州市| 凉山| 惠水县| 横峰县| 伊金霍洛旗| 江源县|