paho.mqtt.javascript
paho.mqtt.javascript copied to clipboard
use common conventions in Client class
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:
Clientshould be an EventEmitterClientshould emitconnectedand other events similarly to net.Socket- The constructor should have a signature similar to net.createConnection
- A factory function should be exposed so that the user needn't use the
newkeyword; alternatively, check forthisin constructor and return a newly constructed object if falsy
This is obviously a breaking change and would necessitate a major version bump.