Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

immutable.js

When should I use `withMutations` on a map in Immutable.js?

December 26, 2023 by Tarik

You should use withMutations when you want to group several changes on an object. Because each change creates a clone, several changes in a row cause several clones. Use withMutations to apply several changes then clone once at the end. A clone at every step means that you are reading the entire list for each … Read more

Categories immutable.js Tags immutable.js Leave a comment

How to describe Immutable.js Map shape with Flow

August 3, 2023 by Tarik

TL;DR; No, but using Records you can get Flow to typecheck the shape but not the types. Longform The correct answer would be: no, since maps don’t have shapes (at least in Flow and Immutable). But Immutable does have a type for “Maps” with shapes. That would be Records. But for reasons described below (since … Read more

Categories immutable.js Tags immutable.js Leave a comment

How to check if object is Immutable?

May 21, 2023 by Tarik

There is an open ticket to improve the API which is on the roadmap for 4.0. Until this is implemented, I suggest you use Immutable.Iterable.isIterable() (docs). Using instanceof is not reliable (e. g. returns false when different modules use different copies of Immutable.js)

Categories immutable.js Tags immutable.js Leave a comment

How to set multiple fields at once in Immutable.js Record?

March 26, 2023 by Tarik

Personally I prefer the merge syntax, it feels more natural: const newContent = oldContext.merge({ “logged”: true, “error”: false }); If you were doing something very complex, maybe the transient version would be better, but I just can’t imagine where. It also means you can leverage mergeDeep if needed.

Categories immutable.js Tags immutable.js Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa