Skip to content

Instantly share code, notes, and snippets.

@chrissiefken
Created August 17, 2013 19:11
Show Gist options
  • Select an option

  • Save chrissiefken/6258318 to your computer and use it in GitHub Desktop.

Select an option

Save chrissiefken/6258318 to your computer and use it in GitHub Desktop.
A thought on how to make JavaScript callbacks and asynchronous code usage simpler by creating a prototype function called 'background'.
regularWork(); //im waiting to leave till im done work
driveHome(); // not executed yet because i'm still at work
background orderStatus = orderPizza('luigis'); // sending my order but I can still do other stuff while i wait
turnOnXbox(); //executed regardless of if my pizza is ready
while(orderStatus == 'not ready') {
playXbox(); //playing till its ready
}
turnOffXbox(); //about to eat
eat(); //mmmmm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment