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

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.

主站蜘蛛池模板: 淳化县| 钦州市| 方城县| 保德县| 大渡口区| 普格县| 高清| 龙井市| 株洲县| 墨竹工卡县| 丰镇市| 绥中县| 方正县| 原阳县| 铅山县| 东阳市| 静安区| 康保县| 南投县| 石渠县| 泾阳县| 湘阴县| 洮南市| 红原县| 济宁市| 阿城市| 营山县| 乌审旗| 广元市| 祁阳县| 抚松县| 雅安市| 珲春市| 开江县| 黄骅市| 吴川市| 金堂县| 灌云县| 勐海县| 囊谦县| 根河市|