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

Executing side-effects


So far, we have an application that provides the initial state and then updates this state in response to user interactions. The final thing we need to build are the actual side-effect functions that execute in response to changing the state.

Rendering episode results

Any piece of state within the results state has the potential to change what's rendered on the screen. If an episode is added, removed, or changed, the list needs to be rendered. If a filter control changes, the list needs to be rendered because the current list might not reflect the current filter settings.

We'll still use the same filtering approach used in Chapter 14, Side-Effects in User Interfaces, though with a few minor adjustments:

const filter = ({
  query,
  title,
  date,
  director,
  rating
}) => every(
  some(
    () => query === undefined,
    () => query === '',
    every(
      () => title,
      v => v.get('title').includes(query)
    ),
    every(
      () => date,
  ...