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

  • Mastering Immutable.js
  • Adam Boduch
  • 75字
  • 2021-07-08 10:30:11

Updating map values

Let's revisit the earlier example where we called update() on a list. Inside of the update function, increment(), we used set() to change the value of map. Map was the list value that we were updating. Let's make map use the update() method as well:

const increment = map => map.update(
'total',
t => t + map.get('step')
);

Instead of having to call map.get('total'), total is passed in as the function argument.

主站蜘蛛池模板: 屯门区| 平果县| 蕲春县| 杭锦旗| 江源县| 大宁县| 黑龙江省| 永嘉县| 益阳市| 东港市| 台东市| 渑池县| 饶阳县| 内江市| 临海市| 桑日县| 牙克石市| 张家界市| 丹巴县| 新野县| 甘泉县| 南平市| 吉水县| 靖江市| 黄冈市| 中江县| 九龙城区| 长子县| 西乌珠穆沁旗| 姚安县| 耿马| 北京市| 卢龙县| 东乌珠穆沁旗| 西丰县| 阿勒泰市| 靖州| 荔浦县| 得荣县| 金华市| 阜南县|