Skip to content

Instantly share code, notes, and snippets.

@rickdaalhuizen90
Created October 16, 2016 21:27
Show Gist options
  • Save rickdaalhuizen90/8c3e67120d6f3c42bc40b978dcafd1ba to your computer and use it in GitHub Desktop.
Save rickdaalhuizen90/8c3e67120d6f3c42bc40b978dcafd1ba to your computer and use it in GitHub Desktop.
Handling Multiple Requests in Node.js
/**
* 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