paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

use common conventions in Client class

Open boneskull opened this issue 7 years ago • 0 comments

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
  • Client should emit connected and 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 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.

boneskull avatar Feb 21 '18 04:02 boneskull