Created
October 16, 2016 21:27
-
-
Save rickdaalhuizen90/8c3e67120d6f3c42bc40b978dcafd1ba to your computer and use it in GitHub Desktop.
Handling Multiple Requests in Node.js
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
/** | |
* Node.js Tutorial for Beginners: Handling Multiple Requests | |
* See: https://www.youtube.com/watch?v=KsjrN-T3ZCs&index=4&list=PL6gx4Cwl9DGBMdkKFn3HasZnnAqVjzHn_ | |
* Credits to: https://github.com/buckyroberts | |
*/ | |
function placeAnOrder(orderNumber){ | |
console.log("Customer order:", orderNumber); | |
cookAndDeliverFood(function (){ | |
console.log("Delivered food orders:", orderNumber); | |
}); | |
} | |
//Simulate a 5 second operation | |
function cookAndDeliverFood(callback){ | |
setTimeout(callback, 5000); | |
} | |
//Simulate users web request | |
placeAnOrder(1); | |
placeAnOrder(2); | |
placeAnOrder(3); | |
placeAnOrder(4); | |
placeAnOrder(5); | |
placeAnOrder(6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment