Created
December 4, 2015 03:35
-
-
Save Trott/a865746d08814af087b7 to your computer and use it in GitHub Desktop.
Can Node use Symbols for the name of an Event? I'd say yep...
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 util = require('util'); | |
const EventEmitter = require('events'); | |
function MyEventEmitter() { | |
EventEmitter.call(this); | |
} | |
// Inherit functions from `EventEmitter`'s prototype | |
util.inherits(MyEventEmitter, EventEmitter); | |
const foo = new MyEventEmitter(); | |
const symbol = Symbol('Hi, Bengie! Err... I mean, Bryan!'); | |
foo.on(symbol, function () { console.log('symbol event fired!'); }) | |
foo.emit(symbol); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
3 years later...
The output will be:
So maybe symbols are not coerced into strings after all / anymore?