Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@eduardorothdev/rxjs-mqtt
Advanced tools
RxJS Wrapper for mqtt with TS support. Based on async-mqtt
npm i @eduardorothdev/rxjs-mqtt
You first need to call and await the connect function, which will return a MqttClient
object with updated methods.
The methods for this MqttClient object are the same as one generated with mqtt
but has the following methods modified:
.publish()
.subscribe()
.unsubscribe()
.end()
.on()
.onJsonMessage<T>()
New method
on()
one, getting only the events of message
sent from the MQTT server, and parsing them to JSON<T>
is the interface or type that the method will try to parse the received messageIn addition to those, I added two more Operator Function helpers that you can chain to the pipe
method of the Observable returned, that will help you easily parse the received events.
parsePayload<T>(parser: (buffer: Buffer) => T | string = (buffer: Buffer) => buffer.toString()
parsePayloadToJSON()
import { connect } from "@eduardorothdev/rxjs-mqtt";
try {
const client = await connect("mqtt://test.mosquitto.org", {
//username: 'user',
//password: 'pass',
});
// subscribe to a topic
await client.subscribe("some/topic/#");
const sub = client
.onJsonMessage<{
some: string;
property: string;
mapping: boolean;
}>()
.pipe(
catchError((err) => {
// we have to catch the error so the
// observable pipe doesn't stop sending messages
return of(null);
}),
)
.subscribe((jsonMessage) => {
// { some: 'hello', property: 'from mqtt', mapping: true }
console.log(jsonMessage);
});
// later you can unsubscribe when needed.
// this will unsubscribe from the onJsonMessage observable pipe
// not from the topic subscription
// sub.unsubscribe();
// Unsubscribe from the topic subscription
// await client.unsubscribe('some/topic/#');
} catch (err) {
// connection/subscription-to-topic errors
console.log(err);
}
Licensed under MIT.
FAQs
RxJS wrapper for MQTT. Based on async-mqtt
The npm package @eduardorothdev/rxjs-mqtt receives a total of 4 weekly downloads. As such, @eduardorothdev/rxjs-mqtt popularity was classified as not popular.
We found that @eduardorothdev/rxjs-mqtt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.