Skip to content

Instantly share code, notes, and snippets.

@quad
Created May 27, 2012 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quad/2816010 to your computer and use it in GitHub Desktop.
Save quad/2816010 to your computer and use it in GitHub Desktop.
Retarded simple event-binding "DSL"
/*
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