Last active
September 22, 2015 13:56
-
-
Save NeoTech/66e5cef7b75613c0f87e to your computer and use it in GitHub Desktop.
Asynchron IO and how it executes.
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
/** | |
* Created by WARMACHINE on 2015-09-22. | |
*/ | |
// Example of code execution in a asynchron enviroment | |
// For simulate lag from db, timeouts will be used. | |
console.log('I will execute first'); | |
var delay1 = 0; | |
setTimeout((function() { | |
delay1 = 1; | |
console.log('I\'m since long forgotten'); | |
}), 500); | |
if(delay1) { | |
console.log('I will execute when timeout is done.'); | |
} else { | |
console.log('I did not execute at all.'); | |
} | |
console.log('I will execute third'); | |
if((function() { return setTimeout((function() { return true; }),500)})) { | |
console.log('But we will wait for this.'); | |
} | |
console.log('Before this...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment