-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Allow us to pass a factory of FirebaseAppConfig to AngularFireModule.initializeApp() #1314
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
Comments
@snakenstein I really like this idea. Would you like to post an API proposal? |
Something like this? class AngularFireModule {
// AngularFireModule.initializeAppWithDependency(
// [MyOwnConfig],
// (ownConfig) => ownConfig.getFirebaseConfig(),
// (ownConfig) => ownConfig.getFirebaseAppName()
// )
static initializeAppWithDependency(dep: any[], configFactory: Function, appNameFactory: Function): ModuleWithProviders {
/*
{ provide: FirebaseAppConfigToken, dep: dep, useFactory: configFactory },
{ provide: FirebaseAppName, dep: dep, useFactory: appNameFactory }
*/
}
} |
Yes, something like what @ippeiukai have suggested. export class Angularfire2WorkaroundConfigModule {
static initializeApp(configFactory: () => FirebaseAppConfig, appNameFactory: () => string) {
return {
ngModule: AngularFireModule,
providers: [
{provide: FirebaseAppConfigToken, useFactory: configFactory},
{provide: FirebaseAppName, useFactory: appNameFactory}
]
};
}
} |
Thinking of this, it would also be cool if we could get rid of the compile-time configuration and get the Firebase config at runtime, like via some call to a config JSON (I recently wrote an article on that). The point is when I'm creating a CD pipeline I'd like to build once and then move that same package from testing, staging to production environment, without the need of rebuilding my Angular app again. That obviously doesn't work when you use the Angular CLI |
@juristr I actually followed your article as example of run-time configuration but running into exactly same issue with Firebase. Do you have any kind of workaround for the time being? |
@jnorkus 😅I ran into this when working on a personal project. For now I don't have a workaround, as I didn't continue the last week working on it. And probably this week neither. Once I have a way to go around this I'll let you know 😄. The main reason I'd like to get these runtime configs is for avoiding to re-build my app when moving between the CD pipeline stages. Apparently right now the best way is to instantiate all the parts manually...but that's something I'd like to avoid. We'll see.. |
We now allow runtime DI in rc7. Will document but give it a shot in the meantime. |
Awesome, thx. Will try it 👍 |
Does anyone have an example of how to "pass a factory of FirebaseAppConfig to AngularFireModule.initializeApp()" or alternative solution using runtime DI? Thanks. |
Hi @jamesdaniels Is this now possible? I cannot find anything in the docs? |
@jamesdaniels can you show us how runtime DI works with a snippet? |
It would be great if we get an option to pass a factory function of
FirebaseAppConfig
toAngularFireModule.initializeApp()
.In some cases such as using a webpack to get enviroment variables and AOT compiler it is impossible now to initialize
AngularFireModule
with correct config parameters. This is because of webpack does not run yet at the moment of module compilation.The ability to pass a factory of
FirebaseAppConfig
to static initialization function would be a solution for this and maybe other similar problems.One related issue already exists: #1281
The text was updated successfully, but these errors were encountered: