Skip to content

Instantly share code, notes, and snippets.

@avhm
Created October 31, 2012 15:59
Show Gist options
  • Save avhm/3987882 to your computer and use it in GitHub Desktop.
Save avhm/3987882 to your computer and use it in GitHub Desktop.
CanJS proposed event changes
var obs = new can.Observe({})
obs.bind('change', func) // Fires once (then, once post timeout) -> just event?
obs.delegate('*','change',func) // Fires once (then, once post timeout) -> just event?
obs.bind('changes', func) // Fires twice (then, once post timeout) -> ev, attr, how, newVal, oldVal
obs.delegate('*','changes', func) // Fires twice (then, once post timeout) -> ev, attr, how, newVal, oldVal
// Should we differentiate between change and changeds?
obs.bind('changed', func); // Fires three times post timeout -> ev, attr, how, newVal, oldVal
obs.delegate('*', 'changed', func); // Fires three times post timeout -> ev, attr, how, newVal, oldVal
var t = can.transaction()
obs.attr({first: "Taylor", last: "Swift"});
setTimeout(function(){
obs.attr("favorite", true);
t();
},1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment