Created
August 17, 2013 19:11
-
-
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'.
This file contains hidden or 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
| 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