Created
October 31, 2012 15:59
-
-
Save avhm/3987882 to your computer and use it in GitHub Desktop.
CanJS proposed event changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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