-
Book Overview & Buying
-
Table Of Contents
Flux Architecture
By :
The Immutable.js library from Facebook provides immutable JavaScript data structures. This might sound trivial but there's a lot that goes on behind the scenes to make this work, namely creating new instances from transformations as efficiently as possible.
In this section, we'll look at immutable lists and maps. These are viable substitutes for arrays and plain objects, respectively, in our Flux store data. Then, we'll look at how Immutable.js can compose complex transformations without the need for intermediary representations. Finally, we'll see how Immutable.js returns the same instance when there's no mutations after running through a transformation, allowing for efficient change detection.
We'll start by looking at lists and maps, since these are fairly common structures that we'll need to implement in our stores. Lists are kind of like arrays and maps are kind of like plain JavaScript objects. Let's implement a store that uses a list:
import...