Skip to content

Instantly share code, notes, and snippets.

@AndrewIngram
Created August 18, 2014 16:00
Show Gist options
  • Save AndrewIngram/0ee71fa20b577b869eb1 to your computer and use it in GitHub Desktop.
Save AndrewIngram/0ee71fa20b577b869eb1 to your computer and use it in GitHub Desktop.
Immutable JS Cursors
var Immutable = require('immutable');
var data = Immutable.fromJS({ a: { b: { c: 1 } } });
data.toJS();
// { a: { b: { c: 1 } } }
var cursor = data.cursor(['a'], function(newData) { data = newData; });
cursor.set('d', 2);
data.toJS();
// { a: { b: { c: 1 }, d: 2 } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment