Skip to content
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

[Quest] Firebase 9 compatibility #178

Closed
4 tasks done
mikkopaderes opened this issue Sep 4, 2021 · 5 comments
Closed
4 tasks done

[Quest] Firebase 9 compatibility #178

mikkopaderes opened this issue Sep 4, 2021 · 5 comments
Assignees

Comments

@mikkopaderes
Copy link
Owner

mikkopaderes commented Sep 4, 2021

Here's the game plan for this

  • Remove dependency with ember-firebase-service and use the compat SDK across the addon. See more details on it below.
  • Release a v2.0.0 for the breaking changes
  • Slowly update the addon to use the modular SDK
  • Release v3.0.0 when addon is 100% compat SDK free (timing might be on Firebase 10 release)

Notes:

  • The game plan for this might change as development goes on
  • By using v2.0.0 you can slowly transition to use the modular SDK in your apps (see here). But in my experience, these transition process may vary and is limited. For common and simple usage of this addon, you may not find anything that will be able to make use of this combination of v8 and v9 SDK API.

Remove dependency with ember-firebase-service

Unfamiliar to some, ember-firebase-service exposes a service that represents firebase.app.App which is heavily used in this addon. Moving forward, this addon will have its own firebase service but will marked as a private service like:

import { inject as service } from '@ember/service';
import Controller from '@ember/controller';

import firebase from 'firebase/app';

export default class Application extends Controller {
  @service('-firebase')
  firebase;
}

In the future, the service will have no purpose in a pure Firebase modular SDK world, hence will be removed. This is the reason why I'll mark it as private, to discourage users from using it.

Users that are using the service should move away from it. Here's a sample migration path:

import { inject as service } from '@ember/service';
import Controller from '@ember/controller';

import firebase from 'firebase/app';

export default class Application extends Controller {
  @service
  firebase;

  createTestRecord() {
    const db = this.firebase.firestore();

    db.collection('users').add({ ... });
  }
}

Instead, you can do:

import Controller from '@ember/controller';

import { addDoc, collection, getFirestore } from 'firebase/firestore';

export default class Application extends Controller {
  createTestRecord() {
    const db = getFirestore();

    addDoc(collection(db, 'users'), { ... });
  }
}

Another small change is how the addon config env is being set up. Here's the migration path:

let ENV = {
  firebase: {
    apiKey: '<api_key>',
    authDomain: '<auth_domain>',
    databaseURL: '<database_url>',
    projectId: '<project_id>',
    storageBucket: '<storage_bucket>',
    messagingSenderId: '<messaging_sender_id>'
  },

  'ember-cloud-firestore-adapter': {
    emulator: {
      hostname: 'localhost',
      firestorePort: 8080,
      authPort: 9099  // optional if not using auth
    },
  },
}

Will now be:

let ENV = {
  'ember-cloud-firestore-adapter': {
    firebaseConfig: {
      apiKey: '<api_key>',
      authDomain: '<auth_domain>',
      databaseURL: '<database_url>',
      projectId: '<project_id>',
      storageBucket: '<storage_bucket>',
      messagingSenderId: '<messaging_sender_id>'
    },

    firestore: {
      settings: { ... },
      emulator: { ... }
    },

    auth: {
      emulator: { ... }
    }
  },
}
@mikkopaderes mikkopaderes self-assigned this Sep 4, 2021
@mikkopaderes
Copy link
Owner Author

Updated the original post for a more detailed plan

@knownasilya
Copy link

Can this be closed?

@mikkopaderes
Copy link
Owner Author

Can this be closed?

I originally plan to once Firebase 10 is released and I remove support for compat SDK. But technically, Firebase 9 is supported already in this addon so I'll try to re-review if this can be closed over the weekend.

@AmilKey
Copy link

AmilKey commented Sep 11, 2024

Do you have plans to add support Firebase 10?

@charlesfries
Copy link
Collaborator

#325 v10 support released in 4.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants