Skip to content

Instantly share code, notes, and snippets.

@canonic-epicure
Created September 16, 2010 07:14
Show Gist options
  • Save canonic-epicure/582090 to your computer and use it in GitHub Desktop.
Save canonic-epicure/582090 to your computer and use it in GitHub Desktop.
// Lets say we have a replica, already stored in the DB and in the live set (I call it - in the scope):
var rep = {
attrib : 'some_value'
}
// then user mutates it with rep.setAttrib('new_value')
var rep = {
attrib : 'new_value'
}
// we create a mutation object, which contain a reference to original + mutation data
var mutation = {
object : rep,
attributeName : 'attrib',
oldValue : 'some_value',
newValue : 'new_value'
}
// after some time we have an array of mutations:
[ mut1, mut2, ... ]
// shallow collapse for this array will only give us a changed portion of the graph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment