I am seeking to implement offline persistence using the Cloud Firestore Javascript SDK in my app. My architecture involves storing firestore as a property for Server-Side Rendering (SSR).
import firebase from "firebase/app";
export class GetFirebase {
private firestore: firebase.firestore.Firestore;
private firebaseApp: firebase.app.App;
private firebaseConfig = {} // contains Firebase configuration
private constructor() {
this.firebaseApp = firebase.initializeApp(this.firebaseConfig);
this.firestore = firebase.firestore();
}
}
When I try to utilize the enablePersistence()
method, it returns void.
this.firestore = firebase.firestore().enablePersistence();
Furthermore, I encounter an issue when attempting:
this.firestore = firebase.firestore();
this.firestore.enablePersistence() // error - cannot adjust settings after initialization of firestore.
I have been searching for a TypeScript or JavaScript equivalent of Dart's cascade operator (Dart Documentation) without success.