更新时间:2021-07-08 10:30:50
coverpage
Title Page
Copyright
Mastering Immutable.js
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Why Immutable.js?
Mutations are destructive
Deleting old data
A scary class of bugs
Persisting changes
The Immutable.js approach
A collections API
Collection methods return new data
Chaining method calls
Unidirectional data flow
What other direction is there?
Subscriptions are out
Data is only created
Implicit side-effects are hard to do
Other libraries similar to Immutable.js
What are we comparing?
Lodash is a good bet
Summary
Creating Immutable Data
Immutable.js constructors
The types of Immutable.js data
Lists
Maps
Ordered maps
Sets
Ordered sets
Sequences
Stacks
Records
Passing JavaScript collections
Passing Immutable.js collections
Using the of() method
Lists of values
Maps of values
Sets of values
Sequences of values
Parsing data using the fromJS() function
Parsing JavaScript arrays
Parsing JavaScript objects
Parsing complex structures
Persistent Changes
Adding values to collections
Pushing values to lists
Adding key-value pairs to maps
Chaining value insertion methods
Pushing multiple list values
Adding multiple map key-value pairs
Changing collection values
Changing list values
Setting list values
Updating list values
Changing map values
Setting map values
Updating map values
Chaining collection mutation methods
Removing values from collections
Removing values from lists
Removing values from maps
Chaining collection removal methods
Emptying collections
Replacing collections with new instances
Using the clear() method
Keeping track of changes
Filtering Collections and Finding Items
Filtering using simple comparisons
Strict equality
Greater than and less than
Filtering by negation
Filtering maps by keys
Filtering string keys
Filtering fancy keys
Finding collection values
Value existence checks
Getting values using find()
Filtering using deep equality
Using the is() function and the equals() method