B4J Question [BANano] Google recommending moving to Modular Approach for Firebase

Mashiane

Expert
Licensed User
Longtime User
Hi there

I have noted that google is no longer recommending accessing firebase via the window object but rather following the modular approach, as depicted below.


B4X:
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';
// Follow this pattern to import other Firebase services
// import { } from 'firebase/<service>';

// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
  //...
};

const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

// Get a list of cities from your database
async function getCities(db) {
  const citiesCol = collection(db, 'cities');
  const citySnapshot = await getDocs(citiesCol);
  const cityList = citySnapshot.docs.map(doc => doc.data());
  return cityList;
}

Whilst I understand that BANano7 has built in functionality for Firebase Messaging. The need for other functionality like FireStore, FireBaseDB etc stands. I am yet to re-check if my past projects with firestore still work and are pondering the effect of this move by google for firebase and how BANano will be affected by this and challenges for developers around similar issues.

I have not yet used BANano.Import / BANano.ImportWait and BANano.Header.AddJavaScriptES6File but don't have a good clue of how these work as yet.

Any thoughts?

Thanks in advance.
 
Last edited:
Top