Immutable JS
immutablejs, Javascript, redux

ImmutableJS Examples For Humans

As I already talked about earlier, we at BlogVault, are redoing our dashboard. We ditched BackboneJS and Underscore templates for flux architecture (Redux) and ReactJS. Redux attempts to make state mutations predictable by imposing certain restrictions on how and when updates can happen. These restrictions are reflected in the three principles of Redux:

  1. Single source of truth
  2.  State is read-only
  3. Changes are made with pure functions

Using ImmutableJS ensures the state is not accidentally mutated, hence strictly following above principles.

Developed and maintained by Facebook, ImmutableJS has a strong community and project itself has 15308 stars and 807 forks on GitHub, at the time of writing. However ImmutableJS currently has one pain point – plain JS examples! If you go through docs, you can find most API examples are in typescript. Understanding or translating this to JS can be difficult for most novice coders. I faced similar issues while getting started. While going through endless SO and GitHub threads I realised I was not alone. In fact I remember seeing a few angry comments, which I do not support, as it goes against the spirit of community. Following this philosophy I decided to note down examples for all APIs for my future reference. This might also help others with similar difficulty.

Most of these examples are basic and should be enough to get started. I have not described any API as its already beautifully done in ImmutableJS docs.

Let me know in comments if I missed anything or made any errors.

Advertisements
Standard

2 thoughts on “ImmutableJS Examples For Humans

  1. Lan says:

    YOU ARE F***ING AWESOME! Thank you! I hate the ImmutableJS docs and you have saved me countless hours trying to understand what the heck it’s doing. Thank You!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s