Check out a free preview of the full Rethinking Asynchronous JavaScript course

The "Quiz" Lesson is part of the full, Rethinking Asynchronous JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

Kyle spends a few minutes quizzing the audience on the async patterns he’s covered up to this point.


Transcript from the "Quiz" Lesson

>> [MUSIC]

>> Kyle: I thought it was a good opportunity for us to take a quick look back at what we've gone through over this workshop. As I said, this represents kind of the baseline that I really want all JavaScript developers to feel like they can get to. So it's kind of a full court press saying, let's get the word out, let's get people practicing and trying to get to that point.

So, let's make sure we understand where we've come, cuz we've come quite a way since the beginning of the workshop, so far. So first, in your own words, how would you describe to me what callback hell is? What is it really?
>> Speaker 2: Inversion of control.
>> Kyle: Inversion of control is one of the key aspects.

What else?
>> Speaker 2: Out of sequence.
>> Kyle: The non-local, non-sequential reasoning. So what is callback hell? Callback hell isn't deficiency of the callbacks pattern alone, when you don't have anything else but the callback. It's not capable of addressing these major deficiencies. One of them being a version of control.

One of them being non-local non-sequential reasoning. So callbacks, while they're the atomic fundamental building block upon which everything we doing, even that fancy generator stuff is still got callbacks happening. But without those additional patterns on top, the callbacks are not capable of addressing these issues. So we need to put higher order patterns on top of them to address those problems.

That's what callback hell really is? You know is that really has very little to do with the nesting an indentation. That's a side symptom of vast, okay. What is a Promise? I gave two or three different metaphoric ways or ways of thinking about what a Promise is. A conceptually speaking, what is a Promise?

>> Speaker 2: It's a placeholder for a value.
>> Kyle: Placeholder for a value. It's a future cheeseburger, right? It's a future value, it's the cheeseburger I'm going to get at some point. What else is it?
>> Speaker 2: Trust.
>> Kyle: That's what it does and we'll get to talking more about what it does in just a minute.

But metaphorically, I gave you at least two other ways of thinking about what it does. Remember, I talked about it being a completion event. It's like an event listener that we get back and we can register for a completion event, in this case is called the then event.

It's another way and another third way of thinking about it is that, it's a callback manager. We pass our callback to the promise system and it manages them in a way that gives us that trust as you just said. We want that trust back. And by passing them into the promise system, we know that promise system are designed with that trust.

So it solves a version of control because instead of passing our callbacks into a third party that we don't trust, instead they give us a promise back a trustable system and we let that system manager called us. So an invert that inversion of control or rather just simply restraints the control that we always have.

How do you pause a generator?
>> Speaker 3: Yield.
>> Kyle: Yield, and how do you resume a generator?
>> Speaker 3:
>> Kyle: .next, and what was that one magical trick for combining generators and promises together?
>> Speaker 3: Yield a promise.
>> Kyle: Yielding a promise, exactly. Yield a promise and then the promise resumes the generator.

It's accurate, okay? Great. You want to read more about generators. I have a four part blog post series to read about it in addition to the books. So there's plenty to go and read in there and I challenge you encourage you to go dig in on this.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now