Skip to content

Instantly share code, notes, and snippets.

@holyzfy
Created August 23, 2013 03:05
Show Gist options
  • Save holyzfy/6315146 to your computer and use it in GitHub Desktop.
Save holyzfy/6315146 to your computer and use it in GitHub Desktop.
an example for node-promise (https://github.com/holyzfy/node-promise)
var promise = require("./promise");
promise.execute(function(callback){
asyncOperation(callback);
}).then(function(result){
console.log("on succ: ", result);
}, function(err) {
console.log("on fail: ", err);
});
function asyncOperation(callback) {
setTimeout(function(){
callback(null, "succ result");
//callback(new Error("an err"));
}, 2000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment