Skip to content

Instantly share code, notes, and snippets.

@JacobTheEvans
Created October 13, 2017 10:50
Show Gist options
  • Save JacobTheEvans/fca1c138e9468a4032dc4a39b4dcbd20 to your computer and use it in GitHub Desktop.
Save JacobTheEvans/fca1c138e9468a4032dc4a39b4dcbd20 to your computer and use it in GitHub Desktop.
Callback recipe example
var cookChicken = function(cb) {
console.log("I am cooking the chicken");
setTimeout(function() {
console.log("Chicken is done");
cb();
}, 2000);
}
var cutVeggies = function() {
console.log("I cut the veggies");
}
var addChicken = function() {
console.log("I added the chicken to the pot");
}
var addVeggies = function() {
console.log("I added the veggies to the pot");
}
console.log("I am cooking now");
cutVeggies();
addVeggies();
cookChicken(addChicken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment