Created
May 25, 2018 18:09
-
-
Save NickNaso/d0ee9f5f1611060b04ab61f17ad4ce2e to your computer and use it in GitHub Desktop.
Inherits from Event Emitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const EventEmitter = require('events').EventEmitter | |
const NativeEmitter = require('bindings')('native_emitter').NativeEmitter | |
const inherits = require('util').inherits | |
inherits(NativeEmitter, EventEmitter) | |
const emitter = new NativeEmitter() | |
emitter.on('start', () => { | |
console.log('### START ...') | |
}) | |
emitter.on('data', (evt) => { | |
console.log(evt) | |
}) | |
emitter.on('end', () => { | |
console.log('### END ###') | |
}) | |
emitter.callAndEmit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment