Skip to content
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

.on() doesnt register multiple listeners #203

Open
yesitsfebreeze opened this issue May 13, 2022 Discussed in #202 · 4 comments
Open

.on() doesnt register multiple listeners #203

yesitsfebreeze opened this issue May 13, 2022 Discussed in #202 · 4 comments

Comments

@yesitsfebreeze
Copy link

Discussed in #202

Originally posted by yesitsfebreeze May 13, 2022
Would it be possible to implement the on listener in a different way to this?
Currently the problem is that you cant register multiple listeners via .on, due to the fact that the callback is passed into the lambda.
https://github.com/geckosio/geckos.io/blob/master/packages/server/src/geckos/channel.ts#L272

this would be sufficient i guess:

listener = (callback, ....) => {
  ...
}.bind(callback)

this.eventEmitter.on(eventName, listener)
```</div>
@github-actions
Copy link

This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Mar 10, 2023
@yandeu yandeu removed the Stale label Mar 10, 2023
@bananu7
Copy link

bananu7 commented Mar 12, 2023

Actually, does that mean that only one listener can be active at a time? I was struggling a bit because there's no removeListener/removeAllListeners exposed...

@bananu7
Copy link

bananu7 commented Mar 12, 2023

I've just tested and it seems that the subsequent calls to .on() are ignored. For reference, I worked around it by binding via a proxy:

this.channel.on('spectating', (data: Data) => {
    if (this._onSpectating)
        this._onSpectating(data);
});

That's a bit more annoying than just being able to override the handler.

Copy link

This issue is stale because it has been open 500 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jul 25, 2024
@yandeu yandeu removed the Stale label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants