-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(): Switching over to firebase
from @firebase/*
#1677
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
import { InjectionToken, NgZone, NgModule, Optional } from '@angular/core'; | ||
import { app, auth, apps, database, firestore, functions, initializeApp, messaging, storage } from 'firebase/app'; | ||
|
||
import { FirebaseOptionsToken, FirebaseNameOrConfigToken } from './angularfire2'; | ||
// Public types don't expose FirebaseOptions or FirebaseAppConfig | ||
export type FirebaseOptions = {[key:string]: any}; | ||
export type FirebaseAppConfig = {[key:string]: any}; | ||
|
||
import firebase from '@firebase/app'; | ||
import { FirebaseApp as _FirebaseApp, FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types'; | ||
import { FirebaseAuth } from '@firebase/auth-types'; | ||
import { FirebaseDatabase } from '@firebase/database-types'; | ||
import { FirebaseMessaging } from '@firebase/messaging-types'; | ||
import { FirebaseStorage } from '@firebase/storage-types'; | ||
import { FirebaseFirestore } from '@firebase/firestore-types'; | ||
import { FirebaseFunctions } from '@firebase/functions-types'; | ||
export const FirebaseOptionsToken = new InjectionToken<FirebaseOptions>('angularfire2.app.options'); | ||
export const FirebaseNameOrConfigToken = new InjectionToken<string|FirebaseAppConfig|undefined>('angularfire2.app.nameOrConfig') | ||
|
||
export class FirebaseApp implements _FirebaseApp { | ||
export type FirebaseDatabase = database.Database; | ||
export type FirebaseAuth = auth.Auth; | ||
export type FirebaseMessaging = messaging.Messaging; | ||
export type FirebaseStorage = storage.Storage; | ||
export type FirebaseFirestore = firestore.Firestore; | ||
export type FirebaseFunctions = functions.Functions; | ||
|
||
export class FirebaseApp implements app.App { | ||
name: string; | ||
automaticDataCollectionEnabled: boolean; | ||
options: {}; | ||
auth: () => FirebaseAuth; | ||
// app.App database() doesn't take a databaseURL arg in the public types? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI @jshcrowthe |
||
database: (databaseURL?: string) => FirebaseDatabase; | ||
// automaticDataCollectionEnabled is now private? _automaticDataCollectionEnabled? | ||
// automaticDataCollectionEnabled: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI @jshcrowthe, if this goes public again it's going to be a breaking change for us; as it was the first time; as we need to export an "implementing" class to ngModule. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be a lot better for us if |
||
messaging: () => FirebaseMessaging; | ||
storage: (storageBucket?: string) => FirebaseStorage; | ||
delete: () => Promise<void>; | ||
|
@@ -28,8 +34,9 @@ export function _firebaseAppFactory(options: FirebaseOptions, nameOrConfig?: str | |
const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]'; | ||
const config = typeof nameOrConfig === 'object' && nameOrConfig || {}; | ||
config.name = config.name || name; | ||
const existingApp = firebase.apps.filter(app => app.name === config.name)[0]; | ||
return (existingApp || firebase.initializeApp(options, config)) as FirebaseApp; | ||
const existingApp = apps.filter(app => app && app.name === config.name)[0]; | ||
// We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any | ||
return (existingApp || (initializeApp as any)(options, config)) as FirebaseApp; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI @jshcrowthe |
||
} | ||
|
||
const FirebaseAppProvider = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @jshcrowthe