Complete the code to enable offline persistence in Firebase Firestore.
firebase.firestore().[1]();Calling enablePersistence() activates offline data persistence in Firestore.
Complete the code to catch errors when enabling offline persistence.
firebase.firestore().enablePersistence().catch(function([1]) { if ([1].code == 'failed-precondition') { console.log('Multiple tabs open, persistence failed.'); } });
The error object is commonly named error in the catch function.
Fix the error in the code to enable offline persistence with multi-tab support.
firebase.firestore().enablePersistence([1]: true});The correct option to enable multi-tab synchronization is synchronizeTabs.
Fill both blanks to handle the 'unimplemented' error when enabling persistence.
firebase.firestore().enablePersistence().catch(function(error) {
if (error.code === [1]) {
console.log('Persistence is not available in this browser.');
}
else if (error.code === [2]) {
console.log('Multiple tabs open, persistence failed.');
}
});The 'unimplemented' code means persistence is not supported. 'failed-precondition' means multiple tabs conflict.
Fill all three blanks to initialize Firestore with offline persistence and multi-tab synchronization.
const db = firebase.firestore(); db.[1]([2]: true).catch(function(error) { if (error.code === [3]) { console.log('Persistence failed due to multiple tabs.'); } });
Use enablePersistence with synchronizeTabs: true to enable offline support across tabs. The error code 'failed-precondition' indicates multiple tabs conflict.