- Notifications
You must be signed in to change notification settings - Fork1.4k
-
BetaWas this translation helpful?Give feedback.
All reactions
It looks likefromEvent infers the type of event handler argument in a way that does not consider the actual event name, butMqttClient has different handler signatures for each event.
You end up with the arguments for thepacketsend event, which is(packet: Packet), when you wanted the arguments for themessage event, which is(topic: string, payload: Buffer, packet: IPublishPacket).
I don't see a clean way to fix this, other than overriding the return type:
import{connect,IClientOptions,IPublishPacket,OnMessageCallback,Packet}from"mqtt";import{fromEvent,typeObservable}from"rxjs";//...constmessage$=fromEvent(powerLinesMQTTClient,"message")asunknownasObservable<P…
Replies: 2 comments 1 reply
-
I'm not a fan of RxJS and I sincerly have no clue where the error could come from. The only thing that comes to my mind is that we use a custom TypedEventEmitter implementation that may be the cause of your issues: https://github.com/mqttjs/MQTT.js/blob/main/src/lib/TypedEmitter.ts I kindly ask you to do some tests your own and open a PR to fix this if you find a solution |
BetaWas this translation helpful?Give feedback.
All reactions
-
It looks like I don't see a clean way to fix this, other than overriding the return type: import{connect,IClientOptions,IPublishPacket,OnMessageCallback,Packet}from"mqtt";import{fromEvent,typeObservable}from"rxjs";//...constmessage$=fromEvent(powerLinesMQTTClient,"message")asunknownasObservable<Parameters<OnMessageCallback>>; |
BetaWas this translation helpful?Give feedback.
All reactions
👀 1
-
Appreciate for answers |
BetaWas this translation helpful?Give feedback.
