moscajs / aedes

Barebone MQTT broker that can run on any stream server, the node way
MIT License
1.78k stars 231 forks source link

[bug] Aedes interface should extends EventEmitter in types declaration #624

Open cjimenezsaiz opened 3 years ago

cjimenezsaiz commented 3 years ago

System Information

Describe the bug From the PR #596, where TypeScript types were refactored, Aedes interface does not extends EventEmitter, but declare on interface to subscribe to each event. With this new types declaration is not possible to unsubscribe (without tricks) from the events in a TypeScript code that uses aedes.

To Reproduce In a TypeScript application try to use any EventEmitter method, except on.

Expected behavior Aedes interface should extends EventEmitter in types declaration

Additional context Aedes in Typescript application

robertsLando commented 3 years ago

@cjimenezsaiz Could you submit a PR?

cc @gnought

cjimenezsaiz commented 3 years ago

Yes, here you have it #625

gnought commented 3 years ago

@cjimenezsaiz It is intended to remove aedes Typescript definition, as we don't require to inherit all EventEmitter methods for aedes operations. The basic is what your user cases are to unsubscribe the events?

cjimenezsaiz commented 3 years ago

@gnought Aedes has several events and handlers that allow to implement very specific functionality, especially for client connection control or publication control, this handlers are assigned when you instantiate the class, so to change one of this strategies in runtime, you need instantiate a new one (of course there is other patterns, but strategy is the most common), if you don't unsubscribe from events, you will create memory leaks.