Skip to content

Commit 4a5f098

Browse files
committed
chore(modules): Organizing Firebase module imports
1 parent c7ca07a commit 4a5f098

File tree

5 files changed

+10
-32
lines changed

5 files changed

+10
-32
lines changed

src/angularfire2.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import * as firebase from 'firebase/app';
22
import * as utils from './utils';
33
import { FirebaseAppConfigToken, FirebaseApp, _firebaseAppFactory } from './app/index';
44
import { FirebaseListFactoryOpts, FirebaseObjectFactoryOpts, FirebaseAppConfig } from './interfaces';
5-
import { FirebaseAppName } from './tokens';
65
import { Injectable, InjectionToken, OpaqueToken, NgModule } from '@angular/core';
76

7+
const FirebaseAppName = new InjectionToken<string>('FirebaseAppName');
8+
89
export const FirebaseAppProvider = {
910
provide: FirebaseApp,
1011
useFactory: _firebaseAppFactory,
@@ -26,4 +27,4 @@ export class AngularFireModule {
2627
}
2728
}
2829

29-
export { FirebaseApp, FirebaseAppConfigToken, FirebaseAppConfig }
30+
export { FirebaseApp, FirebaseAppName, FirebaseAppConfigToken, FirebaseAppConfig };

src/app/firebase.app.module.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Injectable, Inject, InjectionToken, NgModule, ModuleWithProviders } from '@angular/core';
1+
import { InjectionToken, } from '@angular/core';
2+
import { FirebaseAppConfig } from '../interfaces';
23
import * as firebase from 'firebase/app';
34

4-
export const FirebaseAppConfigToken = new InjectionToken('FirebaseAppConfigToken');
5+
export const FirebaseAppConfigToken = new InjectionToken<FirebaseAppConfig>('FirebaseAppConfigToken');
56

67
export class FirebaseApp implements firebase.app.App {
78
name: string;
@@ -13,7 +14,7 @@ export class FirebaseApp implements firebase.app.App {
1314
delete: () => firebase.Promise<any>;
1415
}
1516

16-
export function _firebaseAppFactory(config: {}, appName?: string): FirebaseApp {
17+
export function _firebaseAppFactory(config: FirebaseAppConfig, appName?: string): FirebaseApp {
1718
try {
1819
if (appName) {
1920
return firebase.initializeApp(config, appName);
@@ -25,24 +26,3 @@ export function _firebaseAppFactory(config: {}, appName?: string): FirebaseApp {
2526
return firebase.app(null);
2627
}
2728
}
28-
29-
export const FirebaseAppProvider = {
30-
provide: FirebaseApp,
31-
useFactory: _firebaseAppFactory,
32-
deps: [ FirebaseAppConfigToken ]
33-
};
34-
35-
@NgModule({
36-
providers: [FirebaseAppProvider]
37-
})
38-
export class FirebaseAppModule {
39-
static initializeApp(config): ModuleWithProviders {
40-
return {
41-
ngModule: FirebaseAppModule,
42-
providers: [
43-
{ provide: FirebaseAppConfigToken, useValue: config },
44-
FirebaseAppProvider,
45-
]
46-
}
47-
}
48-
}

src/database/database.module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { NgModule } from '@angular/core';
22
import * as firebase from 'firebase/app';
33
import 'firebase/database';
4-
import { FirebaseApp } from '../app/index';
5-
import { AngularFireModule } from '../angularfire2';
6-
import { AngularFireDatabase } from './index';
4+
import { AngularFireModule, FirebaseApp } from '../angularfire2';
5+
import { AngularFireDatabase } from './database';
76

87
export function _getAngularFireDatabase(app: FirebaseApp) {
98
return new AngularFireDatabase(app);

src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface FirebaseAppConfig {
77
databaseURL?: string;
88
storageBucket?: string;
99
messagingSenderId?: string;
10+
projectId?: string;
1011
}
1112

1213
export interface FirebaseOperationCases {

src/tokens.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)