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

Nested Freezers #12

Closed
kuraga opened this issue Apr 3, 2015 · 2 comments
Closed

Nested Freezers #12

kuraga opened this issue Apr 3, 2015 · 2 comments

Comments

@kuraga
Copy link
Contributor

kuraga commented Apr 3, 2015

Good day!

Can I store Freezer object in a Freezer object?

@arqex
Copy link
Owner

arqex commented Apr 3, 2015

Hi @kuraga

You mean to have more than one copy of a node? Like...

var store = new Freezer({ a: [1,2,3]}),
  data = store.get()
;

data.set({b: data.a});

This is possible and really useful, everytime you update a, b will be updated since they are the same object. If they have different parents the parents of both will be updated.

If you mean a complete Freezer object, it is possible, but not really useful, because changes in the inner freezer won't trigger an update event in the outer one.

If you want to listen to changes in a specific node you can use the getListener method:

// Continuing the previous example
var listener = data.a.getListener();

listener.on('update', function(){
  console.log('hey!')
}

data.a.push(4); // logs hey!

@kuraga
Copy link
Contributor Author

kuraga commented Apr 3, 2015

Thanks!

@kuraga kuraga closed this as completed Apr 3, 2015
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