Last active
June 20, 2017 03:55
-
-
Save BayMinimum/eaad5a45f9d32cd51955664b3ae22254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(param, callback){ | |
setTimeout(()=>{ | |
var res = some_blocking_function() | |
callback(res) | |
}, 0) | |
} | |
function foo2(param, callback){ | |
if(param_is_wrong) callback("Wrong Parameter", -1) | |
else{ | |
setTimeout(()=>{ | |
var res = some_blocking_function() | |
callback(false, res) | |
}, 0) | |
} | |
} | |
foo(1, (res)=>{ | |
console.log(res) | |
}) | |
foo2(2, (err, res)=>{ | |
if(err) console.log(err) | |
else console.log(res) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment