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

  • 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.

主站蜘蛛池模板: 延吉市| 高陵县| 谢通门县| 崇州市| 巴林左旗| 上饶市| 陇川县| 鄂托克旗| 郧西县| 松潘县| 奎屯市| 容城县| 牡丹江市| 山东省| 大冶市| 蒙山县| 红河县| 康定县| 洛隆县| 大埔区| 灵宝市| 安岳县| 河南省| 扎鲁特旗| 手机| 千阳县| 上杭县| 鹤壁市| 克东县| 咸阳市| 罗山县| 黑河市| 英吉沙县| 珠海市| 宝清县| 邵东县| 绥芬河市| 施甸县| 双辽市| 大竹县| 延庆县|