Skip to content

Instantly share code, notes, and snippets.

@yuanyan
Created September 8, 2011 15:18
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 yuanyan/1203648 to your computer and use it in GitHub Desktop.
Save yuanyan/1203648 to your computer and use it in GitHub Desktop.
un-nested callback
// callback-nested
Database.connect("db",function(db){
db.open("table",function(table){
table.select("name",function(val){
console.log(val);
});
});
});
// un-nested
Function.run(
function(){
Database.connect("db", this.callback);
},
function(db){
db.open("table", this.callback);
},
function(table){
table.select("sql", this.callback);
},
function(val){
console.log(val);
}
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment