Chapter 9

Event-Driven Programming and Built-In Modules

Learning Objectives

By the end of this chapter, you will be able to:

  • Use event modules in Node.js
  • Create an event emitter to enhance the functionality of existing code
  • Build custom event emitters
  • Use built-in modules and utilities
  • Implement a timer module to get an API to schedule timer functions

In this chapter, we will use event emitters and built-in modules to avoid creating projects with deeply coupled dependencies.

Introduction

In the previous chapter, we talked about how event-driven programming is used in Node.js and how we can modify normal callback-based async operations to use async-await and promises. We know that the Node.js core API is built on async-driven architecture. ...

Get Professional JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.