Created
July 1, 2016 15:19
-
-
Save nickylimjj/247c6ed05c6efcd49b9e5d5e8ac7f4b3 to your computer and use it in GitHub Desktop.
NodeJS: non-blocking I/O
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
// understanding the Event Loop and async nature of nodejs | |
// resource help from : https://www.codeschool.com/blog/2014/10/30/understanding-node-js/ | |
function submitOrder(orderNumber){ | |
console.log('Submitted order and cooking: ' + orderNumber) | |
cookingFood(function afterEvent(){ | |
console.log('food is cooked and ready to be delivered') | |
}) | |
} | |
// 5s operation | |
function cookingFood(cb){ | |
setTimeout(cb,5000) | |
} | |
submitOrder(1) | |
submitOrder(2) | |
submitOrder(3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment