The full video and many others like it are all available as part of our Frontend Masters subscription.

Kyle Simpson

Kyle Simpson is an Open Web Evangelist from Austin, TX, who's passionate about all things JavaScript. He's an author, workshop trainer, tech speaker, and OSS contributor/leader.

Kyle Simpson

You Don't Know JS

For this exercise, you will be using the files in the day1/ex5 folder. Look at the file for exercise instructions. In the interest of time, Kyle gives this exercise to the audience as a "homework" assignment.

Get Unlimited Access Now

Kyle Simpson: Unfortunately, I'm going to have to assign you yet another piece. I'd hoped that we could get a chance to go through this. There is a this exercise 5, this a brand new one that I just created, so you guys are the first ones to see this. But I really encourage you to spend some time tonight playing with it, because it's actually kind of fun.

What the task is, it's a fake AJAX load but it requires you to load up three separate files in parallel. You're going to try to get the contents of those files at the same time, so you want to do it in parallel but it wants to make sure that you print them out in the proper order.

And that's a deceptively simple sounding task, that's actually a little bit complex to figure out. I've implemented it using callbacks, and you can see how difficult it is to manage the state with nested callbacks. Then the challenge for you is using whatever promises or generators syntax you like, whatever library, I've shown you how to do it with a sequence, and I've also shown you how to do it, there's files in there to do it with a sequence and also with native Promises.

But whichever format you want, I want you to try to solve that task. How could I load up three separate things but make sure they print in the proper order because that is a real world asynchronous task that we face in our code. I wish we have time to kind of talk through it.

If you guys have questions about it, please feel free to email.
Speaker 1: It could maybe take ten minutes tomorrow morning.
Kyle Simpson: Yeah, we'll probably go over the exercise, if you guys get a chance tonight, we'll probably go over the exercise. That's a good idea. Speaking of tomorrow, tomorrow is going to look somewhat different than today in terms of the style of the way the class goes.

Just to prepare you guys as you're packing up, the style for tomorrow is going to be a lot more code and a lot less lecture. That may or may not be what you're hoping for but there will be a lot less slides, a lot less of me standing for long periods of time and talking and we're going to do a lot more tinkering at the code.

You're going to write real world node code, and the goal is to take what we learned today as a foundation of confidence so that we can write code in our node JS processes without worrying about how these mechanisms work. We'll revisit asynchronicity and we'll revisit a whole bunch of these other things as we deal with.

I appreciate everybody's time today and all your great questions and participation. I look forward to tomorrow, to the second day. If you have any questions, let me know but I appreciate it very much.

Ready to take your code to the next level?

Intense courses with world-class teachers and unlimited access to our growing library of videos for the great price of $39 per month.

Get Unlimited Access Now