Transcript from the "Callback Queue & Event Loop" Lesson
[00:01:10] It's called an event loop. The event loop is just the process of going, hold on. Is my call stack empty? Does my callback queue have a function in it? Don't worry. Call stack was not empty, was not empty, check, check, check, check, check. Still not empty, block for one second is on the way.
[00:01:33] Check, check, still not empty. Still block one, aha, don't panic. Now the call stack's empty, block for one second has finished executing. I can add print hello's call to my call stack. Hooray. The event loop is just a posh name for that checking is my call stack empty?
[00:01:53] Well if it is I can add my callback function that was deferred from using this built in set time out that speaks in the web browser API's. Stores a reference of that function. And on completion of my API, completes instantly. Pushes that function, to the call back queue, where it waits ready to go back to the call stack, when the event loop says it is okay.
[00:02:40] Even though the function printHello looked like it was only gonna be deferred for 0 milliseconds, it took over 1,000 milliseconds. All right folks. We're gonna have to look at one more API like this. Besides timer, there's a whole bunch of different API's we can use. Timer and whole bunch of other ones.