Dexie cloud check if online
Is there a way to check if the cloud db is in offline or online (syncing available) mode? I would like to render certain components conditionally depending on status. I could hit an arbitrary http endpoint, but am hoping there is/can be a useLiveQuery access for connection status.
There's a property db.cloud.syncState which is an instance of Rx' BehaviorSubject. If you are in ReactJS, you can consume the observable using react-use' useObservable. The properties of the result is a SyncState with property status that can be any of "not-started" | "connecting" | "connected" | "disconnected" | "error" | "offline". Where "disconnected" means that user has been idle for more than 3 minutes and the client has chosen to disconnect the websocket until user performs arbritary action such as mouse move, keypress, scroll etc - which will lead to "connecting" followed by "connected" unless something goes bad - "error".
Theres an example in SyncStatusIcon.tsx of the todo-app.
This is working well for me.