Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow multiple Firebase Apps in single site #2451

codercatdev started this conversation in Ideas
Discussion options

Change AngularFireModule providers to include factories

Allow for the FirebaseAppConfig to be passed using a Factory, so that you can dynamically set each app.

Changing

export declare class AngularFireModule {
 static initializeApp(options: FirebaseOptions, nameOrConfig?: string | FirebaseAppConfig): ({
 ngModule: typeof AngularFireModule;
 providers: {
 provide: InjectionToken<string | FirebaseAppConfig>;
 useValue: string | FirebaseAppConfig;
 }[];
 })&{ngModule:AngularFireModule};
 constructor(platformId: Object);
 static ɵmod: ɵngcc0.ɵɵNgModuleDefWithMeta<AngularFireModule, never, never, never>;
 static ɵinj: ɵngcc0.ɵɵInjectorDef<AngularFireModule>;
}

to something like this (fully admit not that good with DI).

export declare class AngularFireModule {
 static initializeApp(
options: () => FirebaseOptions,
nameOrConfig?: () => string | FirebaseAppConfig,
): ({
 ngModule: typeof AngularFireModule;
 providers:
 [
 {
 provide: FIREBASE_OPTIONS,
 useFactory: options
 },
 {
 provide: FIREBASE_APP_NAME,
 useFactory: nameOrConfig
 },
 ]
 })&{ngModule:AngularFireModule};
 constructor(platformId: Object);
 static ɵmod: ɵngcc0.ɵɵNgModuleDefWithMeta<AngularFireModule, never, never, never>;
 static ɵinj: ɵngcc0.ɵɵInjectorDef<AngularFireModule>;
}
You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

Let me look into this, it's possible we might change the API in the future, in the meantime I'll better document how to work with multiple apps.

You must be logged in to vote
1 reply
Comment options

dear @jamesdaniels how to work with multiple apps ..?

Thanks in advance

Comment options

Hi @Ajonp , have you got any solution ?.. we have a similar requirement to load firebase config dynamically.

Thanks in advance

You must be logged in to vote
1 reply
Comment options

Somewhat of a solution, it is a little excessive for an example.
https://github.com/ajonp/ajonp-blackcatcms/blob/c8f07154956b3faf49b38e28719b05bf2d124646/src/app/components/webapp/guards/logged-in-user-role.guard.ts#L35

This application logs you into all your GCP projects and allows you to turn them into Firebase Projects (it lists FB projects as well). You are able to then log into or create several web applications, which intern allows you to log into each site using AngularFireAuth.

You can try it here https://ajonp-blackcatcms-beta.web.app/, but I haven't worked on it in a long time unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
Converted from issue

This discussion was converted from issue #2451 on December 10, 2020 02:47.

AltStyle によって変換されたページ (->オリジナル) /