-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Separate callback for each subscribe call like Aedes.subscribe() #1951
Comments
I suggest you to implement this yourself by creating a wrapper around subscribe/unsubscribe functions using mqemitter library. I don't want to add another library to match topic patterns as this is quite easy to do for end users. Also this library should work both in browser and on nodejs |
I have already created wrapper (same code for both node and browser) without any other package. Another library is not needed comparison seems to be easy...
Btw: It would be great to document that after Client.end() subscriptions are remembered and will be reused when later is manually called Client.connect() or Client.reconnect(). |
From docs:
Do you want to submit a PR? Remember to add unit tests as well |
Is your feature request related to a problem? Please describe.
I'm always frustrated when I subscribe to more topics and must find correct message in shared callback on.message using very long switch or if/elseif.
Describe the solution you'd like
I would like to have ability to call subscribe with one topic (can include + and #) and separate callback. Exactly like npm aedes has... Aedes has this feature and it is great because supports + and # https://github.com/moscajs/aedes/blob/HEAD/docs/Aedes.md#aedessubscribe-topic-deliverfunc-callback Im very missing something like this in npm mqtt package.
Maybe it could be easy implemented by looking for source code of aedes. Also Chat GPT suggest good looking idea how to compare subscribe pattern with received message without regexp and run appropriate subscription callback.
The text was updated successfully, but these errors were encountered: