I have an existing Svelte 4 app which uses stores.I would like to rewrite it to Svelte 5 and make reusable function or class which synchronizes reactive states (runes) for any app states. $states should be synchronized both ways (like bind in components) some only one way (send) like $derived.
Backend can be MQTT or WebSocket and it is synchronizing states between clients.There can be tens of variables to sync and I don't want to write 20 $effects for sending and 20 ifs for subscriptions.
MQTT Component with $bindable props would maybe work, but as I understand components should be mounted to DOM, and syncing variables to MQTT has nothing to do with DOM.