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

Allow subscribing to multiple topics at once with same callback #188

Open
Arcanorum opened this issue Jan 3, 2021 · 1 comment
Open

Comments

@Arcanorum
Copy link

Would be nice to be able to set the same callback for multiple topics at once, for cases where you want the same thing to happen for any of a set of events.

Something like

PubSub.subscribe([EVENT_1, EVENT_2, EVENT_3], (msg, data) => {
    ...
}),
@mroderick
Copy link
Owner

I don't know if this addresses your issue, but you don't have to use anonymous functions as the receiver of notifications.

function callback(msg, data) {
  // ...
}

PubSub.subscribe(EVENT_1, callback);
PubSub.subscribe(EVENT_2, callback);
PubSub.subscribe(EVENT_3, callback);

Additionally, you can use hierarchical adressing to solve the problem of subscribing to multiple events.

If you really need to have PubSub.subscribe([EVENT_1, EVENT_2, EVENT_3], callback); then I suggest creating a pull request.

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

2 participants