Learn how Immutable.js data structures are different from native iterable Javascript data types and why they provide an excellent foundation on which to build your application's state.

Instead of them being mutable, they're always immutable, meaning they don't change from underneath you. The reference to them can change, but the data inside them cannot, which means you can build predictable and reliable state models on top of them. It becomes a lot easier to manage your application's state.

console.clear();

const ary = ["todo1", "todo2"];
const ary2 = ary;
console.log(ary[0]); // todo1 ary2[0] = "done1";
console.log(ary[0]); // done1 // Immutable function updateState(immutable, pos, value) {
return immutable.set(pos, value);
} const immutableState = Immutable.List(["foo1", "foo2"]);
const immutableState2 = immutableState.set(0, "bar1"); console.log(immutableState.get(0)); // foo1
console.log(immutableState2.get(0)); // bar1

Every time you use set() to set a new value, Immutable will return a new array.

[Javascript] Manage Application State with Immutable.js的更多相关文章

  1. [React] Use React Context to Manage Application State Through Routes

    We’ll create a Router component that will wrap our application and manage all URL related state. We’ ...

  2. Immutable.js – JavaScript 不可变数据集合

    不可变数据是指一旦创建就不能被修改的数据,使得应用开发更简单,允许使用函数式编程技术,比如惰性评估.Immutable JS 提供一个惰性 Sequence,允许高效的队列方法链,类似 map 和 f ...

  3. [Javascript] Creating an Immutable Object Graph with Immutable.js Map()

    Learn how to create an Immutable.Map() through plain Javascript object construction and also via arr ...

  4. [Immutable.js] Converting Immutable.js Structures to Javascript and other Immutable Types

    Immutable.js provides several conversion methods to migrate one structure to another. Each Immutable ...

  5. [Immutable.js] Using fromJS() to Convert Plain JavaScript Objects into Immutable Data

    Immutable.js offers the fromJS() method to build immutable structures from objects and array. Object ...

  6. 大话immutable.js

    为啥要用immutable.js呢.毫不夸张的说.有了immutable.js(当然也有其他实现库)..才能将react的性能发挥到极致!要是各位看官用过一段时间的react,而没有用immutabl ...

  7. Redux进阶(Immutable.js)

    更好的阅读体验 更好的阅度体验 Immutable.js Immutable的优势 1. 保证不可变(每次通过Immutable.js操作的对象都会返回一个新的对象) 2. 丰富的API 3. 性能好 ...

  8. Immutable.js 以及在 react+redux 项目中的实践

    来自一位美团大牛的分享,相信可以帮助到你. 原文链接:https://juejin.im/post/5948985ea0bb9f006bed7472?utm_source=tuicool&ut ...

  9. React+Immutable.js的心路历程

    这段时间做的项目开发中用的是React+Redux+ImmutableJs+Es6开发,总结了immutable.js的相关使用姿势: Immutable Data 顾名思义是指一旦被创造后,就不可以 ...

随机推荐

  1. php练习——打印半金字塔、金字塔、空心金字塔、菱形、空心菱形

    半金字塔 金字塔 空心金字塔 菱形     空心菱形

  2. ab基本用法

    ab的全称是ApacheBench,是 Apache 附带的一个小工具,专门用于 HTTP Server 的benchmark testing,可以同时模拟多个并发请求.前段时间看到公司的开发人员也在 ...

  3. LightOj_1284 Lights inside 3D Grid

    题目链接 题意: 给一个X * Y * Z 的立方体, 每个单位立方体内都有一盏灯, 初始状态是灭的, 你每次操作如下: 1)选择一个点(x1, y1, z1)     再选择一个点(x2, y2, ...

  4. Spring MVC小结1

    由于最近刚开始学Spring MVC,所以来讲一下自己的理解. 首先进行环境配置: 1.jdk 2.myeclipse 3.tomcat 4.maven 配置maven的时候出现了一个小的问题,JAV ...

  5. 【POJ3710】Christmas Game (博弈-树上的删边问题)

    [题目] Description Harry and Sally were playing games at Christmas Eve. They drew some Christmas trees ...

  6. 【UVA1579】俄罗斯套娃 Matryoshka (动态规划)

    题目: 分析: 其实就是两个dp结合起来.第一个dp求区间[l,r]全部合并起来要用的最小次数,可以用区间[l,k]&[k+1,r]转移(l<=k<r).第二个dp求前i个娃娃分成 ...

  7. JVM参数配置大全

    前阵子遇到几个面试题都是关于对Java内存控制的,因此从网上找到这篇文章,希望自己对Java的内存分配有重新的认识 /usr/local/jdk/bin/java -Dresin.home=/usr/ ...

  8. Microsoft Internet Explorer 内存破坏漏洞(CVE-2013-3193)(MS13-059)

    漏洞版本: Microsoft Internet Explorer 6 - 10 漏洞描述: BUGTRAQ ID: 61678 CVE(CAN) ID: CVE-2013-3193 Windows ...

  9. 别再说“我已经努力了”,你的“努力”一文不值!

    有次,让一个研究生男收集一份资料,快下班了问结果,竟然毛也没有.见我要怒,他慷慨激昂地说:"我已经很努力找了,但真的查不到." 作为主管,"我已经努力"这话我不 ...

  10. MongoDB 权限管理 用户名和密码的操作

    在刚安装完毕的时候MongoDB都默认有一个admin数据库,而admin.system.users中将会保存比在其它数据库中设置的用户权限更大的用户信息.  当admin.system.users中 ...