1.3.0 • Published 2 years ago

async-mqtt-mustache-events v1.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

async-mqtt-mustache-events

Installation

$ npm install async-mqtt-mustache-events

Description

async-mqtt-mustache-events is a wrapper over async-mqtt and it resolves two issues:

- This lib creates an event on each subscription. Thus when you get a new 
message you don't need to detect from where the topic gets it. 
(You have better code without if's and switches)

- If you need to subscribe on topic with modifiable params then you can use 
a style like mustache template style. (more information in examples)

Examples

Include

const MQTT = require("async-mqtt-mustache-events");
const client = MQTT.connect("tcp://somehost.com:1883"); 

.subscribe(topic, event_name)

//subscriber
client.subscribe(`temperature/{room}`, 'temperatureFromHome');
//listener
client.on('temperatureFromHome', (props, msg)=>{
    console.log(props);
    //{room: 'WS'}
    console.log(msg)
    // '23°C'
});

//tool subscribe on "temperature/+" topic in mqtt

.unsubscribe(event_name)

client.unsubscribe('temperatureFromHome')

.publish(topic, message)

client.publish('temperature/WS', '23°C')
1.3.0

2 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago