import { MqttClient } from 'mqtt' export class Listener { private readonly event: string private readonly cb: any private client: MqttClient constructor (event, cb, client) { this.event = event this.cb = cb this.client = client } public attach (): void { this.client.on(this.event, this.cb) } public detach (): void { this.client.removeListener(this.event, this.cb) } }