All Projects → KeKs0r → mqtt-react

KeKs0r / mqtt-react

Licence: other
React container for MQTT

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mqtt-react

flutter im demo
📞 Flutter 使用 MQTT实现IM功能
Stars: ✭ 81 (+92.86%)
Mutual labels:  mqtt-client
hfeasy
HFeasy - firmware for HF-LPx100/LPx30 based devices
Stars: ✭ 35 (-16.67%)
Mutual labels:  mqtt-client
owlos
DIY Open Source OS for building IoT ecosystems
Stars: ✭ 43 (+2.38%)
Mutual labels:  mqtt-client
homie-device
NodeJS port of Homie for IoT
Stars: ✭ 20 (-52.38%)
Mutual labels:  mqtt-client
Adafruit CircuitPython MiniMQTT
MQTT Client Library for CircuitPython
Stars: ✭ 51 (+21.43%)
Mutual labels:  mqtt-client
mica-mqtt
基于 java aio 实现的低延迟、高性能百万级 mqtt client 组件和 mqtt broker 服务。🔝🔝 记得右上角点个star 关注更新!
Stars: ✭ 128 (+204.76%)
Mutual labels:  mqtt-client
Android-MQTT-Demo
An android application to demonstrate the complete MQTT lifecycle.
Stars: ✭ 31 (-26.19%)
Mutual labels:  mqtt-client
swift-mqtt
MQTT client for Swift using SwiftNIO
Stars: ✭ 33 (-21.43%)
Mutual labels:  mqtt-client
MQTTnet
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
Stars: ✭ 3,309 (+7778.57%)
Mutual labels:  mqtt-client
UnrealMosquitto
A MQTT client with blueprint support for Unreal Engine 4, based on Mosquitto.
Stars: ✭ 41 (-2.38%)
Mutual labels:  mqtt-client
javascript
Nodejs MQTT client for emitter.io.
Stars: ✭ 27 (-35.71%)
Mutual labels:  mqtt-client
net-mqtt-client-react
Asynchronous MQTT client built on React
Stars: ✭ 45 (+7.14%)
Mutual labels:  mqtt-client
tuya-home-assistant
Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
Stars: ✭ 684 (+1528.57%)
Mutual labels:  mqtt-client
python-mqtt-client-shell
Python-based MQTT client command shell
Stars: ✭ 45 (+7.14%)
Mutual labels:  mqtt-client
swift-nio-mqtt
MQTT v5.0 client powered by SwiftNIO.
Stars: ✭ 23 (-45.24%)
Mutual labels:  mqtt-client
eMQTT5
An embedded MQTTv5 client in C++ with minimal footprint, maximal performance
Stars: ✭ 51 (+21.43%)
Mutual labels:  mqtt-client
ESP8266 WiFi v2.x
ESP8266 WiFi for OpenEVSE Version 2.x
Stars: ✭ 72 (+71.43%)
Mutual labels:  mqtt-client
mqtt-cli
MQTT CLI is a useful command line interface for connecting various MQTT clients supporting MQTT 5.0 and 3.1.1
Stars: ✭ 211 (+402.38%)
Mutual labels:  mqtt-client
nmqtt
Native Nim MQTT client library
Stars: ✭ 39 (-7.14%)
Mutual labels:  mqtt-client
web-mqtt-client
A better MQTT API for the browser
Stars: ✭ 48 (+14.29%)
Mutual labels:  mqtt-client

Build Status

Maintenance

I am not using this library, so it is really hard to maintain it, without knowing the use cases. If someone is interested in taking it over or supporting the maintenance. Please reach out to me. My email is on my profile.

mqtt-react

React Container for mqttjs/MQTT.js

Demo

There is a very minimalistic Demo-App: mqtt-react-demo

Usage

Currently, mqtt-react exports two enhancers. Similarly to react-redux, you'll have to first wrap a root component with a Connector which will initialize the mqtt instance and then subscribe to data by using subscribe.

Root component

The only property for the connector is the connection information for mqtt.Client#connect

Example Root component:

import { Connector } from 'mqtt-react';
import App from './components/App';

export default () => (
  <Connector mqttProps="ws://test.mosca.io/">
    <App />
  </Connector>
);

Subscribe

Example Subscribed component:

import { subscribe } from 'mqtt-react';

// Messages are passed on the "data" prop
const MessageList = (props) => (
  <ul>
    {props.data.map( message => <li>{message}</li> )}
  </ul>
);

// simple subscription to messages on the "@test/demo" topic
export default subscribe({
  topic: '@demo/test'
})(MessageList)

Example Posting Messages

MQTT Client is passed on to subscribed component and can be used to publish messages via mqtt.Client#publish

import React from 'react';
import { subscribe } from 'mqtt-react';

export class PostMessage extends React.Component {
    
  sendMessage(e) {
      e.preventDefault();
      //MQTT client is passed on
      const { mqtt } = this.props;
      mqtt.publish('@demo/test', 'My Message');
  }  
  
  render() {
    return (
      <button onClick={this.sendMessage.bind(this)}>
        Send Message
      </button>
    );
  }
}

export default subscribe({
  topic: '@demo/test'
})(PostMessage)

Advanced Susbcription / Integration with Redux:

It is possible to provide a function that handles received messages. By default the function adds the message to the data prop, but it can be used to dispatch actions to a redux store.

import { subscribe } from 'mqtt-react';
import store from './store';


const customDispatch = function(topic, message, packet) {
    store.dispatch(topic, message);
}


export default subscribe({
  topic: '@demo/test',
  dispatch: customDispatch
})

Credits

Sponsored by nearForm

Contributing

Pull Requests are very welcome!

If you find any issues, please report them via Github Issues!

Contributors

License

(MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].