Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pivot on whole freezer object? #95

Closed
solugebefola opened this issue Nov 4, 2016 · 3 comments
Closed

Pivot on whole freezer object? #95

solugebefola opened this issue Nov 4, 2016 · 3 comments

Comments

@solugebefola
Copy link

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?

@arqex
Copy link
Owner

arqex commented Nov 4, 2016

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.

@solugebefola
Copy link
Author

solugebefola commented Nov 4, 2016

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!

@arqex
Copy link
Owner

arqex commented May 13, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants