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

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.

主站蜘蛛池模板: 伊春市| 黄冈市| 翼城县| 彩票| 鹤岗市| 虞城县| 布拖县| 富平县| 通化市| 张家港市| 金溪县| 澎湖县| 边坝县| 永州市| 门头沟区| 花垣县| 盐城市| 萨嘎县| 高密市| 塘沽区| 雷州市| 息烽县| 慈利县| 沙坪坝区| 来安县| 林甸县| 商洛市| 迭部县| 镇康县| 太和县| 个旧市| 隆尧县| 开江县| 方山县| 嵩明县| 休宁县| 沾益县| 锡林浩特市| 张家界市| 古田县| 遂宁市|