Book Image

Mastering Immutable.js

By : Adam Boduch
Book Image

Mastering Immutable.js

By: Adam Boduch

Overview of this book

Immutable.js is a JavaScript library that will improve the robustness and dependability of your larger JavaScript projects. All aspects of the Immutable.js framework are covered in this book, and common JavaScript situations are examined in a hands-on way so that you gain practical experience using Immutable.js that you can apply across your own JavaScript projects. The key to building robust JavaScript applications using immutability is to control how data flows through your application, and how the side-effects of these flows are managed. Many problems that are difficult to pinpoint in large codebases stem from data that’s been mutated where it shouldn’t have been. With immutable data, you rule out an entire class of bugs. Mastering Immutable.js takes a practical, hands-on approach throughout, and shows you the ins and outs of the Immutable.js framework so that you can confidently build successful and dependable JavaScript projects.
Table of Contents (23 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

A simple application


To demonstrate how Immutable.js applications use side-effects to render UI components, we'll build a very simple application that lists Black Mirror episodes and provides a handful of filter controls. We'll build the exact same user interface using DOM APIs and then do so again with React.

Application data

The application data that we will be rendering is a list of Black Mirror episodes. Each episode is a map with some information about the episode. Here's a truncated version of the list to give you an idea of what it looks like as an Immutable.js collection:

const episodes = List.of(
  Map.of(
    'title', 'The National Anthem',
    'date', 'December 4 2011',
    'director', 'Otto Bathurst',
    'rating', 8.0
  ),
  Map.of(
    'title', 'Fifteen Million Merits',
    'date', 'December 11 2011',
    'director', 'Euros Lyn',
    'rating', 8.3
  ),
  Map.of(
    'title', 'The Entire History of You',
    'date', 'December 18 2011',
    'director', 'Brian Welsh',
    'rating...