-
-
Notifications
You must be signed in to change notification settings - Fork 105
Readd internal ChatClient onPrivmsg handler on removeListener #178
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
Readd internal ChatClient onPrivmsg handler on removeListener #178
Conversation
|
||
removeListener() { | ||
// Doing this with rest params would require a any[] type annotation which is bad and also | ||
// would add a new function signature which is also not wanted thus using `arguments` makes more sense here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the implementation doesn't contribute to the actual signatures. But you don't have to use any[]
either.
Please update the event emitter package (as a hard dependency in package.json! it's a necessary bugfix) and use its new signatures as a base for this. Also drop the .call
from the super call - it's completely unnecessary.
To be honest, a complete fix for this would probably have to completely separate internal and external events. There are many Promise
s that could leak because of calling this function while being connected. With separated events, event handlers wouldn't have to be recreated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the package and fixed the above code by using typescript type guards similar to the new implementation of removeHandlers
.
I assume you meant removeListener(idOrEvent?: Listener | Function, listener?: Function)
by "new signature" and that I should use that one but that signature isn't included with the newly generated type definitons: https://unpkg.com/@d-fischer/typed-event-emitter@3.0.2/lib/EventEmitter.d.ts so I can't use it to just forward the two parameters.
I'm sorry to say this but I currently don't have enough time to dig into the lib and understand how exactly events are passed so I'm not able to refactor this to use internal and external events.
This is currently unsupported by TS; I'm considering contributing it as a feature. Until then, @ts-expect-error is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed up the way arguments are passed to the superclass. Anyway, thanks for your effort!
Don't worry, I have to close and reopen so that Travis picks the weird rebases up properly. |
@all-contributors please add @daniel0611 for code |
I've put up a pull request to add @daniel0611! 🎉 |
Released as 4.2.5. |
Type: Bugfix
Fixes: #177
Re-registers the internal
onPrivmsg
handler that emits theonMessage
events onremoveListener
.I hope the way I did it is fine, otherwise just let me know.