shehankonecranes / sp-react-native-mqtt

MQTT Client native module for react-native
68 stars 55 forks source link

Creating client with global scope #21

Closed KyleMIrby closed 3 years ago

KyleMIrby commented 3 years ago

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.