eclipse-paho / eclipse-paho/paho.mqtt.javascript
use common conventions in Client class
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 466
- PR merge metrics
- No merged PRs in 30d
Description
Currently, to know when the `Client` class has connected, a user will pass an `onSuccess` callback to the constructor.
It would be best if the `Client` class' API was more familiar. There's no reason that I can see that this class must deviate from common convention, which has been established by Node.js. Ideally:
- `Client` should be an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
- `Client` should emit `connected` and other events similarly to [net.Socket](https://nodejs.org/api/net.html#net_class_net_socket)
- The constructor should have a signature similar to [net.createConnection](https://nodejs.org/api/net.html#net_net_createconnection)
- A factory function should be exposed so that the user needn't use the `new` keyword; alternatively, check for `this` in constructor and return a newly constructed object if falsy
This is obviously a breaking change and would necessitate a major version bump.
Contributor guide
Assessment
This issue has not been assessed yet.