I would like to know how it is possible with angularfire2 to know if the cloud firestore database is accessible and that I can get collection values?
The goal here is if it fails, I will go get local data instead.
I have something like
this.afStore.collection('messages').valueChanges().subscribe(
(messages: any[]) => {
// DO STUFF
});
Thanks
Firestore doesn't expose a concept of being "online" or "offline". Internally, the SDK manages the connection, and retries indefinitely until it can regain its connection. The SDK generally assumes that your app is online, with temporary moments of outage.
Until a connection is regained, the local persistence cache is used to satisfy reads and writes. A read that cannot come from cache waits 10s for a response from the server (unless your connection is really slow). A write that involves a transaction can't be written to local cache - it must be performed while fully online.
You could attempt to check for yourself if there is some sort of connectivity, but that doesn't guarantee that the SDK has an immediately available connection to the service side.