-
Book Overview & Buying
-
Table Of Contents
Web Developer's Reference Guide
By :
In the next group of modules, we will look at utilities. The functions chosen here are used across many different types of applications. We will cover everything from events and cryptology to buffers and npm.
Events are used in many built-in Node objects. This is because emitting and listening for events is the perfect way to let another function know when to start executing. This is especially true in the asynchronous world of Node.js. Anytime we use the on function of an object, it means that it has inherited from EventEmitter. All of the examples will assume that the events variable is already created as follows:
var events = require('events');This is the parent class that can be inherited from to create a new EventEmitter:
events.EventEmitter
Node.js has a fully featured event system that we can easily inherit from and implement. We do not need any extra frameworks or custom code. EventEmitter is the class to inherit from, and we will get...
Change the font size
Change margin width
Change background colour