Transcript from the "Web API Example" Lesson
[00:00:34] Here's our call stack over here. There it is. And here we go, line one, line one, Mark, line one, what do we do my friend?
>> Mark: We're defining a function printHello.
>> Will Sentance: Very nice from Mark, he just came back in and straight on point, excellent from Mark. We're defining a function printHello, there it is.
[00:02:05] All right, here we go. Am I allowed to have someone come to the whiteboard, Mark? No, all right, Ethan, it is your honored moment my friend. Come up here.
>> Ethan: [LAUGH]
>> Will Sentance: Take the blue pen.
>> Ethan: My goodness.
>> Ethan: All right.
>> Will Sentance: It's a long straight line.
>> Speaker 4: [LAUGH]
>> Will Sentance: Is he right? Let's give him a huge hand.
>> Audience: [APPLAUSE]
>> Will Sentance: Thank you, Ethan. One up from Ethan, all right.
>> Brayden: printHello.
>> Will Sentance: Yeah, yeah, sure.
[00:03:15] But something even more important, Jeff?
>> Jeff: Duration.
>> Will Sentance: Duration of the timer, exactly. Which is 1,000 milliseconds. So there we go, 1,000 milliseconds. That is to say, timeouts, consequences, consequences all in the web browser, what feature? It's the timer and it's gonna take 1,000 milliseconds. There it is.
[00:03:43] Now, we're not setting up a timer for no reason, we're setting it up so we can run the function on its completion. So let's have over here On Completion and On Completion, Matt, what are we gonna want to have happen? We want to run printHello.
>> Will Sentance: So you're gonna grab the printHello function as well, and there it is, our printHello.
>> Will Sentance: On completion, beautiful. Now, is it complete? And this is wherefore we're gonna have to add a new part to our puzzle. And that's my green pen that represents time passing. So we're setting this off at roughly 0, beautiful, roughly 0 milliseconds.
[00:04:43] That's when this line triggers the work in the background. At 0 millisecond folk, is this timer, this 1,000 milliseconds timer Dan, is it complete?
>> Dan: It is not.
[00:05:06] Its only job was to do what, Brayden?
>> Brayden: Set the timer.
>> Will Sentance: Set the timer up in the?
>> Brayden: Browser.
>> Will Sentance: In the web browser. That's its only job. So what can we do at that moment after setting up that work, well, at one millisecond, we can move onto what line, Todd?
[00:05:24] What line can we move straight onto?
>> Todd: Console log me first.
>> Will Sentance: We can move straight onto console log Me first! Look at this, people. Straight onto console log me first. There it is, and I will put our console over here. And if anybody tells me it should be in blue, because my brother feature yes, I know but we'll put it over here, me first.
[00:05:51] And look at that, isn't that beautiful, people? At one millisecond, and to be clear by the way, these timings here are what I call ordinal. That means that like they're showing us the order of things happening actually would take like nanoseconds to do that next line, but there's a sort of a milliseconds to be easier and there is me.
>> Todd: Yeah.
>> Will Sentance: Shout out to our favorite big box retailer, there it is.
>> Audience: [LAUGH]
>> Will Sentance: In the web browser, time is passing.
[00:06:37] And at 1,000 milliseconds, Kayla, what do we think is gonna have happened? Is our timer complete?
>> Kayla: Yeah.
>> Will Sentance: It is.
>> Kayla: It's gonna call the function.