-
-
Save PaulRosset/e8e6c9770f37978b0ba009ac01fb115d to your computer and use it in GitHub Desktop.
Understand EventLoop on async operation for Scheduler in rxjs
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
/** | |
* Using process.nextTick(() => {}) | |
* Permit to launch a microtask inside the eventloop that will be executed ASAP | |
*/ | |
setTimeout(() => { | |
console.log("timeout1"); | |
}, 0); | |
function toto() { | |
Promise.resolve().then(() => { | |
console.log("promise2"); | |
}); | |
} | |
function titi() { | |
console.log(7); | |
} | |
Promise.resolve().then(() => { | |
console.log("promise1"); | |
}); | |
console.log(4); | |
toto(); | |
console.log(5); | |
titi(); | |
Promise.resolve().then(() => { | |
console.log("promise3"); | |
}); | |
console.log(6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The exercise is to guess the order of each console.log
Response:
RESPONSES