From the course: Advanced Node.js
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Sequential execution - Node.js Tutorial
From the course: Advanced Node.js
Sequential execution
- [Instructor] In the first lesson, we introduced sequential execution with callbacks and we saw how nesting too many callbacks can create an anti-pattern called callback hell or the pyramid of doom. Let's take a deeper look at this anti-pattern. So inside of our example file, inside of chapter one, chapter one lesson five, the index.js has this huge pyramid of doom. So what's going on here is we're using a couple resources. We're using the file system. We're gonna write and delete the file. And then on line two, we are actually setting up a function that will cause the computer to beep. So if we write the standard output, this \xO7 code, that will actually cause the MacOS to beep, so we will hear a beep when we run this. Now this doStuffSequentially is one function, but this function has a lotta callbacks. So on line five we see that the function is starting, that's the first step. And then on line six, we're gonna set a timeout. We can't see how long that timeout is all the way down…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Callback pattern8m
-
(Locked)
Resolving promises5m 40s
-
(Locked)
Rejecting promises2m 58s
-
(Locked)
The promisify function5m 18s
-
(Locked)
Sequential execution7m 6s
-
(Locked)
Sequential execution with async/await7m
-
(Locked)
Parallel execution4m 6s
-
(Locked)
Concurrent tasks6m 3s
-
(Locked)
Logging concurrent tasks3m 3s
-
-
-
-