Created
May 27, 2012 21:45
-
-
Save quad/2816010 to your computer and use it in GitHub Desktop.
Retarded simple event-binding "DSL"
This file contains 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
/* | |
Retarded simple event-binding "DSL" | |
Best with: | |
* jQuery (or Zepto) | |
* event_emitter | |
https://github.com/ajaxorg/ace/blob/master/lib/ace/lib/event_emitter.js | |
Usage: | |
tie($(window), "hashchange") | |
.to(new TitleUpdater($(".brand .title")), "update") | |
.to(new TextSelector(data, $(".text")), "pull"); | |
*/ | |
function tie(source, e_name) { | |
var chain = {to: function(target, f_name) { | |
source.on(e_name, function(e) { | |
return target[f_name].apply(target, e); | |
}); | |
return chain; | |
}} | |
return chain; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment