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

Updated event and strict mode #29

Open
bredele opened this issue Mar 24, 2014 · 0 comments
Open

Updated event and strict mode #29

bredele opened this issue Mar 24, 2014 · 0 comments
Labels

Comments

@bredele
Copy link
Owner

bredele commented Mar 24, 2014

I added an event 'updated' which is trigerred on set, del and reset. You can choose to trigger or not this event by setting the strict mode to true:

//trigger updated
store.set('name','bredele');

//doesn't trigger updated
store.set('name','bredele', true);

It is used internally (by pipe) and is useful for some plugins. For example, the plugin mirror emit an event to the server on changes, and set its data when some data are received from the server.

store.on('updated', function(name, val) {
  socket.emit('change', name, val);
});

socket.on('change', function(name, val){
  store.set(name, val, true);
});

Without the strict node, we will send date in loop to the server (data from server - set local store and trigger change - send data to server on change).

My question is: is there a better way to prevent to send data in loop to the server?

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

No branches or pull requests

1 participant