Immutable-js: Should there be a pushIn() ?

Created on 15 Feb 2015  路  4Comments  路  Source: immutable-js/immutable-js

I want to append an item to a List deep inside another structure. Would ideally like:

pushIn(keyPath: Array<any>, value: T): List<T>

where the keyPath is one item shorter than an equivalent setIn would be (because the final operation is a push, not a set).

Thoughts?

enhancement

Most helpful comment

There's a bit of a slippery slope where ultimately every API method will have an equivalent *In() parallel. pushIn() makes good sense, so I'll keep this open.

In the meantime, updateIn() is the generic deep update method which all other *In use directly.

foo.updateIn(["a", "b", "c"], List(), list => list.push(123));

The empty list 2nd arg will be used in place of undefined in the update fn should the path not yet exist.

All 4 comments

There's a bit of a slippery slope where ultimately every API method will have an equivalent *In() parallel. pushIn() makes good sense, so I'll keep this open.

In the meantime, updateIn() is the generic deep update method which all other *In use directly.

foo.updateIn(["a", "b", "c"], List(), list => list.push(123));

The empty list 2nd arg will be used in place of undefined in the update fn should the path not yet exist.

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

Has something been done for that issue?

bump

Was this page helpful?
0 / 5 - 0 ratings

Related issues

s-panferov picture s-panferov  路  4Comments

Delapouite picture Delapouite  路  3Comments

kopax picture kopax  路  3Comments

Daniel15 picture Daniel15  路  4Comments

davidwparker picture davidwparker  路  3Comments