(options: FirebaseOptions, zone: NgZone, nameOrConfig?: string | FirebaseAppSettings | null)
| 11 | |
| 12 | |
| 13 | export function ɵfirebaseAppFactory(options: FirebaseOptions, zone: NgZone, nameOrConfig?: string | FirebaseAppSettings | null) { |
| 14 | const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]'; |
| 15 | const config = typeof nameOrConfig === 'object' && nameOrConfig || {}; |
| 16 | config.name = config.name || name; |
| 17 | // Added any due to some inconsistency between @firebase/app and firebase types |
| 18 | const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0]; |
| 19 | // We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any |
| 20 | // Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206 |
| 21 | const app = (existingApp || zone.runOutsideAngular(() => firebase.initializeApp(options, config as any))); |
| 22 | try { |
| 23 | if (JSON.stringify(options) !== JSON.stringify(app.options)) { |
| 24 | const hmr = !!(module as any).hot; |
| 25 | log('error', `${app.name} Firebase App already initialized with different options${hmr ? ', you may need to reload as Firebase is not HMR aware.' : '.'}`); |
| 26 | } |
| 27 | } catch (e) { /* empty */ } |
| 28 | return new FirebaseApp(app); |
| 29 | } |
| 30 | |
| 31 | const log = (level: 'log'|'error'|'info'|'warn', ...args: any) => { |
| 32 | if (isDevMode() && typeof console !== 'undefined') { |
no test coverage detected