Skip to content

Instantly share code, notes, and snippets.

@quirkey
Created September 12, 2010 02:38
Show Gist options
  • Save quirkey/575782 to your computer and use it in GitHub Desktop.
Save quirkey/575782 to your computer and use it in GitHub Desktop.
// Given a function that accepts a callback with the functions response
// executes the function waiting for the callback, and setting `content`
// to the returned value before preceeding to the next item in the queue.
async: function(fun, callback) {
return this.then(function(content) {
var context = this;
this.wait();
fun(function(response) {
context.next(response);
});
return false;
}).then(callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment