SvelteStack / svelte-query

Performant and powerful remote data synchronization for Svelte
https://sveltequery.vercel.app
MIT License
822 stars 30 forks source link

`onlineManager` listeners only called when using `setOnline(true)` #85

Open pzcfg opened 2 years ago

pzcfg commented 2 years ago

We have custom logic in our app that uses setOnline(false) if our server isn't reachable. We were running into issues trying to react to this with onlineManager, and it seems the reason for this is that onOnline() (which calls the listeners) is only called when setOnline() is called with a truthy value.

Screen Shot 2022-04-21 at 4 19 52 PM

This is different from the window's online status, which calls onOnline() for both online and offline events, so this seems like a bug.

Screen Shot 2022-04-21 at 4 25 08 PM

The listeners should either be called both when going online and offline, or there should be an additional way to listen for going offline.