Skip to content

Instantly share code, notes, and snippets.

@BenjaminVerble
Created October 5, 2016 05:00
Show Gist options
  • Save BenjaminVerble/86d06fc2f9d94aa647a96e47ccdb6254 to your computer and use it in GitHub Desktop.
Save BenjaminVerble/86d06fc2f9d94aa647a96e47ccdb6254 to your computer and use it in GitHub Desktop.

Revisions

  1. Benjamin Verble created this gist Oct 5, 2016.
    8 changes: 8 additions & 0 deletions immutable-nested.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    import Immutable from 'immutable'

    const nested = Immutable.fromJS({a:1, b:2, pieces:[]})
    const nested2 = nested.updateIn(['pieces'], list => list.push({player: 'player1'}));
    const nested3 = nested2.updateIn(['pieces'], list => list.push({player: 'player2'}));
    bin.log(nested3.toJS())
    const nested4 = nested3.updateIn(['pieces'], list => list.pop())
    bin.log(nested4.toJS())