Skip to content

Instantly share code, notes, and snippets.

@mrgenixus
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save mrgenixus/9098239 to your computer and use it in GitHub Desktop.

Select an option

Save mrgenixus/9098239 to your computer and use it in GitHub Desktop.
function resolve(cb, res){
$.when(res).then(cb)
}
//usage:
function definePurpleEventually(cb){
setTimeout(function(){
cb({
purple: "color"
})
}, 1000);
}
function getPurpleDef(cb) {
cb($.ajax('/purple'));
}
function whatIsPurple(purpleDef){
console.log(purpleDef.purple);
}
definePurpleEventually(_.partial(resolve, whatIsPurple));
getPurple(_.partial(resolve, whatIsPurple));
//There has GOT be be a better idiom!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment