NgxMqttClient
This is a MQTT.js wrapper which provides reactive and strongly typed api for mqtt.
Getting started
Install via npm/yarn
npm install --save ngx-mqtt-client
yarn add ngx-social-login
Import the module
Import NgxMqttClientModule
into your Module
.
It is also possible to import into multiple modules if you need multiple mqtt connections.
@
How to use
@ implements OnDestroy messages: Array<Foo> = ; status: Array<string> = ; { /** * Tracks connection status. */ this_mqttServicestatus; } /** * Manages connection manually. * If there is an active connection this will forcefully disconnect that first. * @param */ : void this_mqttService; /** * Subscribes to fooBar topic. * The first emitted value will be a {@see SubscriptionGrant} to confirm your subscription was successful. * After that the subscription will only emit new value if someone publishes into the fooBar topic. * */ : void this_mqttServicesubscribeTo<Foo>'fooBar' ; /** * Sends message to fooBar topic. */ : void this_mqttServicepublishTo<Foo>'fooBar' bar: 'foo'; /** * Unsubscribe from fooBar topic. */ : void this_mqttService; /** * The purpose of this is, when the user leave the app we should cleanup our subscriptions * and close the connection with the broker */ : void this_mqttService;
Demo
git clone https://github.com/wermerb/ngx-mqtt-client.gitcd ngx-mqtt-clientyarn / npm installng serve