-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for offline data? #9
Comments
Hey Colin, it's great than you mention this. This is an important feature to me, and I hope to get some time to implement/investigate this on short notice. My initial thought is to allow initialisation of Firestorter with a promise that resolves to the firestore app object. And then it would work sort of like this: async function init() {
try {
await firebase.firestore().enablePersistence();
}
catch (err) {
if (err.code == 'failed-precondition') {
console.warn('Multiple tabs open, persistence can only be enabled in one tab at a time.');
} else if (err.code == 'unimplemented') {
console.warn('The current browser does not support all of the features required to enable persistence');
}
}
initFirestorter({firebase: firebase});
};
init(); |
Hi, regarding offline persistence, I suggest the following approach which I've been using successfully in my application for some time now. It deals with the problem in 3 phases:
1. Render the application after initialisation has occurredindex.js import React from 'react';
import ReactDOM from 'react-dom';
import firebase from '@firebase/app';
import '@firebase/firestore';
import { initFirestorter } from 'firestorter';
import App from './App';
firebase.initializeApp({...);
async function initFirestore() {
firebase.firestore().settings({ timestampsInSnapshots: true });
try {
await firebase.firestore().enablePersistence();
} catch (err) {
console.error('Failed to enable firebase persistency: ', err.message);
}
initFirestorter({ firebase: firebase });
}
initFirestore().then(() => {
ReactDOM.render(<App>, document.getElementById('root'));
}); 2. Use a
|
It seems like we're still unable to add a new document to a collection while being offline. (and let the collection decide what its auto id should look like) We can't do what is suggested here: firebase/firebase-js-sdk#2030 (comment) with the current's Collection API. |
firestore documentation gives the following example of how to use there built in persistence function. Though it seems like since im using mobx/firestorter this may need to be implemented in a different way. Is this a feature I can utilize using the firestorter API?
The text was updated successfully, but these errors were encountered: