In this video, learn about another important tool that ships with Node.js: the EventEmitter. The EventEmitter is the Node.js implementation of the pub/sub design pattern. Discover how to create a file that creates custom events for an application, and how to create a function that returns random items from an array every second and a half.
- [Instructor] A powerful tool that ships with Node.js…is the Event Emitter.…The Event Emitter is Node.js' implementation…of the Pub-Sub design pattern,…and it gives us a mechanism for emitting custom events,…and wiring up listeners and handlers for those events.…Let's go ahead and mess around with the Event Emitter…by creating a new file within our samples called events.js,…and within this new file the first thing I'm going to do…is get our Events module, so we will create a new variable…called events and we will require our Events module.…
So I don't need to put a path to this module,…because it is a core module that comes with Node.js.…The next thing I need to do is create…an instance of the Event Emitter,…so I'm going to create something called the emitter,…and the emitter is going to be a new Events Event Emitter.…So the Events module comes with an Event Emitter constructor…that will construct a new instance of the Event Emitter…that we can use to raise custom events.…Well, how do we raise a custom event?…
- What is Node.js?
- Installing Node.js
- The global object
- Importing the core modules
- Creating custom events with the EventEmitter
- Reading, writing, and removing files
- Working with file streams
- Creating child processes with the exec and spawn functions
Skill Level Intermediate
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
1. What Is Node.js?
2. Set Up Your Environnment
3. Node Globals
4. Node Modules
5. File System Basics
6. Files and Streams
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.