garyaustin
09/20/2021, 10:41 PMScott P
09/21/2021, 2:05 AM.subscribe
function will return an error if the connection drops / the device goes offline.
Depending on your JS environment, it would probably be best to also implement a network check. For example, with React Native, you could use NetInfo (https://github.com/react-native-netinfo/react-native-netinfo , or for Expo: https://docs.expo.dev/versions/latest/sdk/netinfo/), and then use that as an additional check to confirm if the local network is online.garyaustin
09/21/2021, 2:12 AMScott P
09/21/2021, 2:17 AM.subscribe(result => {
if (result !== "SUBSCRIBED") {
// connection to subscription server dropped
}
})
In my case, I just log a message out in case I need to debug further, but you could use a react hook to trigger a state update to show your apps 'offline' UI elements.
Be aware that at the moment, the main limitation to subscriptions is that they don't support RLS policies - meaning that every message sent via subscription will be sent to everyone that's connected.
This is mainly a limitation of Postgres publications not supporting them, so a custom solution is needed. The team are working on a solution for this, but I'm not sure of the current progress of it.garyaustin
09/21/2021, 2:23 AMgaryaustin
09/21/2021, 1:46 PM