
Mastering Immutable.js
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Person
Adam Boduch has been involved in large-scale JavaScript development for nearly 15 years. Before moving to the frontend, he worked on several large-scale cloud computing products using Python and Linux. No stranger to complexity, Adam has practical experience with real-world software systems and the scaling challenges they pose.
Content
- Cover
- Title Page
- Copyright
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Table of Contents
- Preface
- Chapter 1: 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
- Chapter 2: 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
- Summary
- Chapter 3: 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
- Summary
- Chapter 4: 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
- Searching lists of maps
- Partial matches
- The shape of maps
- Subsets and supersets
- Changing the search direction
- Searching sorted collections
- Using findLast() and reduceRight()
- Summary
- Chapter 5: Sequences and Side-Effects
- Why lazy evaluation?
- Large collections are expensive
- Avoiding unnecessary work
- Chained operations are easy to understand
- Sequence creation and iteration
- Basic sequence creation
- Collections to sequences
- Lists to sequences
- Maps to sequences
- Iterating with for...of loops
- Iterating with forEach()
- Lazy filtering
- Basic lazy filtering
- Multiple filter levels
- Limiting results and reducing work
- Using take() to limit results
- Using slice() to paginate
- Summary
- Chapter 6: Sorting Collections
- Sorting and reversing
- The sort() method
- The reverse() method
- Sorting lists of maps
- The sortBy() method
- Sorting by multiple keys
- Ordered maps
- Order guarantees
- Insertion order is not sort order
- Setting the order with set()
- Sorting maps
- Creating ordered maps
- Sorting maps by key
- Maintaining sort order
- Finding the insertion index
- Is this really necessary?
- Summary
- Chapter 7: Mapping and Reducing
- Mapping lists of maps
- Plucking values
- Computing new values
- Mapping to new lists of maps
- Creating new keys
- Filtering keys
- Reducing collections
- When filtering isn't enough
- Producing minimums and maximums
- Accumulating values
- Lazy mapping
- Multiple map() calls
- Filtering before mapping
- The ultimate lazy pattern
- Summary
- Chapter 8: Zipping and Flattening
- Zipping collections
- Removing excess iterations
- Zipping lists of simple values
- Zipping lists of maps
- Lazy zipping
- Flattening collections
- Avoiding recursion
- Deep flattening nested lists
- Shallow flattening lists
- Flattening nested maps
- Summary
- Chapter 9: Persistent Change Detection
- Collection equality
- Strict equality and mutative methods
- Detecting changes
- Detecting no changes
- Strict equality versus deep equality
- Transformations versus mutations
- Transformations always return new collections
- Detecting changes before transformations
- Caching side-effects
- Summary
- Chapter 10: Working with Sets
- Sets are not lists
- Do not use the get() method
- No defined iteration order
- Maps with keys only
- Removing duplicates
- Converting to sets
- Converting to sets, then back to lists
- Lazy duplicate removal
- Ordered sets
- Sorting sets
- Iterating over sets
- Maintaining sets
- Adding unique values
- Adding duplicate values
- Summary
- Chapter 11: Comparing Collections
- Set intersections
- Intersecting sets
- Ordered intersections
- List intersections
- Reducing list intersections
- Filtering list intersections
- Collection differences
- Set differences
- List differences
- Comparing maps
- Map intersections
- Map differences
- Subsets and supersets
- List subsets
- List supersets
- Summary
- Chapter 12: Combining Collections
- Merging maps
- Merging maps by key
- Merging maps with complex keys
- Merging lists
- Merging simple values
- Merging lists of maps
- Merging lists of lists
- Concatenating lists and sequences
- Simple value concatenation
- Lazy sequence concatenation
- Interposing and interleaving
- Lazily interposing values
- Lazily interleaving values
- Summary
- Chapter 13: Declarative Decision Making
- Mapping behavior
- Keys are logical paths, values are behavior
- Wrapping behavior maps in functions
- Parameters and defaults
- Providing default behavior
- Parameterizing mapped behavior
- Composing behavior
- A generic higher-order behavior function
- Logical and/or conditions
- Complex behavior compositions
- Summary
- Chapter 14: Side-Effects in User Interfaces
- A simple application
- Application data
- Filter controls
- Episode results
- DOM side-effects
- HTML markup
- Filter fields
- Rating slider
- Episode template
- Filtering episodes
- Handling events
- Rendering elements
- React side-effects
- Application state
- Handling events and changing state
- Mapping episodes to elements
- Summary
- Chapter 15: Side-Effects in Node.js
- Reading data into collections
- Reading and parsing CSV data
- Reading large amounts of data
- Using concat()
- Using push()
- Using push() and withMutations()
- Writing collection data
- Iterating over collections and writing lines
- Asynchronous data and sequences
- Chaining lazy sequences and streams
- Summary
- Chapter 16: Immutable Architecture
- The reusable application state updater
- Initial state
- Side-effects
- Updating state and running side-effects
- Initial application state
- Result state
- Creating a new episode state
- Events and state updaters
- Updating the search query
- Updating the checkboxes and slider state
- Updating new episode data
- Creating new episodes
- Executing side-effects
- Rendering episode results
- Rendering the result count
- Resetting the new episode form
- Summary
- Index
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.