-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is emitting on a symbol channel supported? #201
Comments
This hasn't actually been tested before. My gut feeling is that it won't work nicely if you have wildcards enabled since the event string gets split up by separators and turned into a tree (which won't work with Symbol as it's not a string type). |
That's what I figured too. Would you be interested in a PR to support Symbols, or is it beyond the scope of this lib? |
If it didn't hurt performance, I could see it being a useful addition. Though I don't know if it'd really be worth bringing everything else in if all you want is an event emitter that uses symbols. |
I wonder if you could model nested/wildcard channels with Symbols too: import { EventEmitter2, Any } from 'eventemitter2'
const A = Symbol('A')
const B = Symbol('B')
const emitter = new EventEmitter2
emitter.on(A, () => {})
emitter.on([A, B], () => {})
emitter.on([A, Any], () => {}) |
Yeah, at that point I'd probably suggest making a separate symbol-based version. It should be easy enough to create a tree using an array of symbols and use that for looking up listeners. |
…wildcard events; Optimize recursivelyGarbageCollect function;
The text was updated successfully, but these errors were encountered: