1.0.10 • Published 4 years ago

mqtt-hooks v1.0.10

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

mqtt-react-hooks

CircleCI Maintainability Test Coverage Language grade: JavaScript

Pub/Sub communication with an MQTT broker using React Hooks

Almond

Simple but complicated mqtt hook

Overview

This library is focused to help you to connect, publish and subscribe to a Message Queuing Telemetry Transport (MQTT) in ReactJS with the power of React Hooks. The library is a modification of mqtt-react-hooks found here.

Flow of Data

  1. WiFi or other mobile sensors publish data to an MQTT broker
  2. ReactJS subscribes to the MQTT broker and receives the data using MQTT.js
  3. React's state is updated, and the data is passed down to stateless components

Hooks Available

  • useMqttState -> return { status, mqtt }
  • useSubscription(topic) -> return { mqtt, status, lastMessage }

Usage

Currently, mqtt-react-hooks exports one enhancers. Similarly to react-redux, you'll have to first wrap a root component with a Connector which will initialize the mqtt instance.

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

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