How can I create an MQTT client with global scope so that I can call publish upon certain events in the app. I have tried setting the client equal to the MQTT.createClient(options) function such as:
However, this does not work, as all of the client functions are not recognized beyond this point. Perhaps my thinking is wrong, but I would appreciate any help or guidance in this problem.
Hello,
How can I create an MQTT client with global scope so that I can call publish upon certain events in the app. I have tried setting the client equal to the MQTT.createClient(options) function such as:
const client = MQTT.createClient({ uri: 'mqtt://broker.hivemq.com:1883', clientId: 'your_client_id' });
However, this does not work, as all of the client functions are not recognized beyond this point. Perhaps my thinking is wrong, but I would appreciate any help or guidance in this problem.