Complete the code to preload a Firebase bundle using the SDK.
const bundleTask = firebase.firestore().bundle('[1]');
The bundle name is passed as a string to the bundle() method to start preloading.
Complete the code to listen for progress updates while loading a Firebase bundle.
bundleTask.onProgress(([1]) => { console.log('Progress:', [1]); });
The onProgress callback receives a snapshot object with progress details.
Fix the error in the code to correctly load a Firebase bundle from a Uint8Array.
firebase.firestore().loadBundle([1]).then(() => console.log('Bundle loaded'));
The loadBundle method expects a Uint8Array containing the bundle bytes, commonly named bundleBytes.
Fill both blanks to create a listener that handles bundle loading progress and completion.
bundleTask.onProgress(([1]) => { if ([2].taskState === 'Success') { console.log('Bundle loaded successfully'); } });
The callback receives a snapshot object, which has a taskState property to check if loading succeeded.
Fill all three blanks to preload a bundle, listen for progress, and handle completion.
const bundleTask = firebase.firestore().bundle('[1]'); bundleTask.onProgress(([2]) => { console.log('Progress:', [2].bytesLoaded); if ([2].taskState === '[3]') { console.log('Bundle fully loaded'); } });
Use the bundle name string for bundle(), snapshot as the progress parameter, and check if taskState equals 'Success' to confirm loading.