The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Querying an Immutable.js Map()

Querying an Immutable.js Map()

4:47
Learn how to query an Immutable.Map() using get, getIn, has, includes, find, first and last. These are powerful operators that make finding data in an object graph pain free.
Watch this lesson now
Avatar
egghead.io

Learn how to query an Immutable.Map() using get, getIn, has, includes, find, first and last. These are powerful operators that make finding data in an object graph pain free.

Avatar
awv-inf

The official immutable.js docs are impossible to read, that is why people come here.

But instead of learning how these functions work we're covering wrappers, abstractions and tests.

I really wish you would have just used the functions as they are, show what they return, thereby cutting the lessons time in half. Right now i am not sure if i better crawl through robotic typescript definitions than watch yet another test that calls this and that wrapper named differently than the immutable method way outside the view comparing results not shown.

Avatar
J.S.

Hi @awv-inf. Thanks for the feedback. Some love the TDD approach and others have expressed your same concern. Will definitely try to find a happy medium in the future!

In reply to awv-inf
Avatar
Kostiantyn

I suppose you have the typo in the case "should find nested keys":

var todos = Immutable.Map();
    var todos2 = Immutable.Map();

    _.each(_.range(10), (index) => {
      todos = ....
    });

    _.each(_.range(10), (index) => {
      todos = ...
    });

The second one for _.each should be todos2... Am I right? Because if we check console.log(todos.size) right after the _.each... the result will be 1...

I such case we can goo deeper and verify it:

const todo2ID = todos2.last().id;
expect(multipleTodoStates.getIn(["todo2", todo2ID], null)).to.equal(todos2.last());
Avatar
Shreya

TDD is a good approach to teaching a new library,
However the author could have used more imagination while naming variables. "todo" this and "todo" that... was not the easiest to follow.

Also the helper functions should have been avoided.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?