emqx / MQTTX

A Powerful and All-in-One MQTT 5.0 client toolbox for Desktop, CLI and WebSocket.
https://mqttx.app
Apache License 2.0
3.64k stars 428 forks source link

fix(desktop): share one message event #1684

Closed ysfscream closed 4 weeks ago

ysfscream commented 4 weeks ago

What is the current behavior?

The current subscribers of the observer repeatedly process a message multiple times.

image

What is the new behavior?

By using shareReplay(1), the message processing results are cached and shared, avoiding duplicate processing while ensuring all subscribers can correctly handle different messages. These changes ensure that each message is processed only once without affecting the original business logic and functionality. Please describe the new behavior or provide screenshots.

image

Does this PR introduce a breaking change?