# async-mqtt-mustache-events

> Event wrapper over async-mqtt

Latest version **1.3.0** (published 2022-10-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-mqtt-mustache-events
pnpm add async-mqtt-mustache-events
yarn add async-mqtt-mustache-events
bun add async-mqtt-mustache-events
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2022-10-23 |
| First published | 2020-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | DanZBo |
| Maintainers | danzbo |

## Links

- npm: https://www.npmjs.com/package/async-mqtt-mustache-events
- Repository: https://github.com/DanZBo/async-mqtt-mustache-events
- Homepage: https://github.com/DanZBo/async-mqtt-mustache-events#readme
- Issues: https://github.com/DanZBo/async-mqtt-mustache-events/issues
- npm.io page: https://npm.io/package/async-mqtt-mustache-events

## Dependencies (1)

- [async-mqtt](https://npm.io/package/async-mqtt.md) ^2.6.3

## Recent versions

- 1.3.0 (latest) — 2022-10-23
- 1.2.5 — 2020-12-09
- 1.2.3 — 2020-12-04
- 1.2.2 — 2020-12-04
- 1.2.1 — 2020-12-04
- 1.1.2 — 2020-11-17
- 1.1.1 — 2020-10-15
- 1.1.0 — 2020-08-06
- 1.0.4 — 2020-07-22
- 1.0.3 — 2020-07-07
- 1.0.2 — 2020-04-13
- 1.0.1 — 2020-04-08
- 1.0.0 — 2020-04-07

## README

# 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
```javascript
const MQTT = require("async-mqtt-mustache-events");
const client = MQTT.connect("tcp://somehost.com:1883"); 
```
### .subscribe(topic, event_name)
```javascript
//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)
```javascript
client.unsubscribe('temperatureFromHome')
```

### .publish(topic, message)
```javascript
client.publish('temperature/WS', '23°C')
```

---
_Source: https://npm.io/package/async-mqtt-mustache-events · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
