An immutable collection preserves its stored value after creation. Operations that appear to modify it instead produce a new collection version, preventing accidental mutation and making behavior easier to predict. section 9.1 section 1.2.2
Use immutable collections to:
- Share data safely between components and pass it through generic data-manipulation functions. section 11.0
- Represent state as multiple preserved versions rather than updating one collection in place. section 4.0
- Support deterministic replay when function contexts contain serializable immutable data. section 15.7
Creating a changed version
Immutable.js uses accessors such as Immutable.getIn() and creates changed versions with Immutable.setIn(). A publication year can therefore change without modifying the original nested collection. section 9.3.2
Listing 4.2 Using _.set as an immutable function
var nextLibraryData = _.set(libraryData,
["catalog", "booksByIsbn",
"978-1779501127", "publicationYear"],
1986);
Inspect the Lodash FP example that updates a nested library value immutably through an information path. section 4.2























