Closed donniekerr closed 2 years ago
Hi Donnie,
Good question! In the next version, I’ll release the feature that can allow users to register connected/disconnected/excepted event.
Hi @donniekerr,
I've released the new version 1.2.14 that can register events to listen mqtt status.
For example:
mqttHook.registerEvent(
'on-connect', // mqtt status: on-connect, on-reconnect, on-disconnect, on-connect-fail
(topic: string, message: string) => {
console.log('mqtt connected')
},
'string_key',
)
mqttHook.unRegisterEvent('on-connect', 'string_key')
Awesome! Thanks @tommy44458 much appreciated. It will be useful to others as well.
@tommy44458 I see the connection status in the console but how do I access it? I need to update UI when client connects, disconnects, or has an error.