EventEmitter interface inconsistentSee original GitHub issue
Describe the bug
EventEmitter interface is based on NodeJS
So, it’s possible to have the following error when calling native emitter functions not implemented by custom emitter:
(node:89665) UnhandledPromiseRejectionWarning: TypeError: emitter.off is not a function
In my example I tried to call the
off function of native emitter.
Either a typescript error must be thrown at compile time.
off function of native emitter is available on custom class
Or all native emitter function are available.
I can make the fix asap after best solution has been chosen:
EventEmitterinterface with custom class methods
offmethod to custom class
- expose native emitter from custom class.
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
If you encounter an issue and already have a solution just submit a PR with it otherwise small issues like that will just be resolved.
@faustbrian thank you for fixing this quickly.
It would have been also great to discuss it a little bit more before.
1/ The done “bugfix” doesn’t really fix the underlying issue: the Ark
emitter.EventEmitter type is not a NodeJS
events.EventEmitter and several other methods are missing, such as
These methods used to be available with
eventemitter3, removed by #2329, which have introduced an API breaking change and have impacted our Unik-Name implementation of Ark core (see https://github.com/ArkEcosystem/AIPs/issues/70).
emitter.EventEmitter could inherit from
events.EventEmitter and override a few methods to update the max count of listeners.
2/ @nigui had already done a private fix when he described the issue. So a fix for this issue has been done twice. This can bee seen as “lost time”. Was this issue critical enough to fix it so quickly (5h)?
So, for the next time, can you please tell us:
- either Ark team is not interested in external contributions
- or interested by Github’s PRs with some code, without discussing