File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -162,3 +162,22 @@ added.
162162This event is emitted * after* a listener is removed. When this event is
163163triggered, the listener has been removed from the array of listeners for the
164164` event ` .
165+
166+ ### Inheriting from 'EventEmitter'
167+
168+ Inheriting from ` EventEmitter ` is no different from inheriting from any other
169+ constructor function. For example:
170+
171+ ``` js
172+ ' use strict' ;
173+ const util = require (' util' );
174+ const EventEmitter = require (' events' ).EventEmitter ;
175+
176+ function MyEventEmitter () {
177+ // Initialize necessary properties from `EventEmitter` in this instance
178+ EventEmitter .call (this );
179+ }
180+
181+ // Inherit functions from `EventEmitter`'s prototype
182+ util .inherits (MyEventEmitter, EventEmitter);
183+ ```
You can’t perform that action at this time.
0 commit comments