Created
January 5, 2018 23:26
-
-
Save MarkoCen/bb7c904b89f17cdbb3deb26aeacae528 to your computer and use it in GitHub Desktop.
[Markoenv.org Post] Nodejs Event Emitter Sample 1
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
const EventEmitter = require('events'); | |
const event = new EventEmitter(); | |
// 添加一个事件监听器 | |
event.on('bar', function() { | |
console.log('bar fired!'); | |
}) | |
// 触发一个事件 | |
event.emit('bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment