freezer
freezer copied to clipboard
Pivot on whole freezer object?
Maybe I am mistaken, but when I try to pivot on an entire freezer object, I don't get back the object, but rather the changed node.
free = new Freezer({a: {b:1, c:2}, d: ["hah", "ho", "hee"], e: [{ze: "zo", zd: "zing"}]});
first = free.get()
//{ a: { b: 1, c: 2 }, d: [ 'hah', 'ho', 'hee' ], e: [ { ze: 'zo', zd: 'zing' } ] }
first.pivot() //Works fine, gives back original
//{ a: { b: 1, c: 2 }, d: [ 'hah', 'ho', 'hee' ], e: [ { ze: 'zo', zd: 'zing' } ] }
second = first.pivot().a.set({b:95})
//Gives back changed node { b: 95, c: 2 }
Am I using it incorrectly?
Hi @solugebefola
it seems that you found some kind of bug when pivot on the root. I need to have a look at the code and check what's happening, but if you need the root object is always a good idea to write freezer.get()
, a bit more verbose but you are always sure that you are working with the synced data.
Ordinarily I would, but I am not using Freezer in the typical fashion, I don't think. I am including it in a standard react component and using a freezer object (e.g. 'first' in the above) derived from the Freezer ('free') as an attribute in the state. Then i am using standard setState on the freezer object rather than using the Freezer. So I was trying to modify only a portion of the freezer object and return the whole thing as the argument for setState. If this were a project starting from scratch, I would probably use free.get()
with a listener rather than setState, but the situation doesn't allow it without a lot of modification to the underlying code. Thanks for letting me know I wasn't crazy!
Hey @solugebefola,
Sorry for my late late reply. I have tested it and for me it's working fine
http://jsbin.com/mizumamota/1/edit?js,console
I don't know if some update has fixed it.