Connected signal snippet

Some operations, such as persisting Models and Collections, cannot be performed until the client has successfully connected to the MQTT broker. So if you happen to send a signal before the connection is established it will have no effect. I created a simple component that sends a signal when the client is connected, you can use this to e.g. fetch Models and Collections on startup.

Connected Signal Snippet.zip (1.2 KB)

1 Like

Hi @mikaeltellhed,

Thanks for the snippet, would you mind giving a really basic example (screenshot?) of how could would be integrated.

Thanks!

Sure. First I import the snippet with the import local project button in the library popup.

I used it in my project to trigger a Fetch on a collection when the client loaded.

The Collection has persistence mode “Global” which requires me to manually fetch the content (as opposed to Sync, which I actually later changed to). I first had it connected to a switch but then the signal triggered before the MQTT connection was established, and the fetch could not be completed.

1 Like