How to pass Firebase database to use - to a library

507 views
Skip to first unread message

ty.sh...@gmail.com

unread,
Apr 1, 2019, 10:58:27 AM4/1/19
to Firebase Google Group
Before Angular 6 I would ng build --env=[ENVIRONMENT FILE] and the environment file would have the firebase configuration to use. 

In Angular 7, since libraries don't have the "--env" option, how would let my library know which firebase configuration to use?

Especially in light of the fact that in my library I have to initialize AngularFire with a configuration.

In my library I have . . . but I need the environment to be dynamic. Right now as you can see its static.

import { NgModule } from '@angular/core';

// Angular
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule } from '@angular/fire/database';
import { AngularFireAuthModule } from '@angular/fire/auth';

import { environment } from '../environments/environment';

export const firebaseConfig = environment.firebaseConfig;


@NgModule({
  declarations: [

  ],
  imports: [
    SixteenDataModule,
    AngularFireModule.initializeApp(firebaseConfig),
  ],
  exports: [
    AngularFireAuthModule,
    AngularFireDatabaseModule,
    AngularFireModule,
  ]
})

Kato Richardson

unread,
Apr 3, 2019, 2:17:06 PM4/3/19
to Firebase Google Group
I think you just use --configuration instead? See this primer.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d581d322-7b4e-4c93-bfa2-8e186cec0b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

ty.sh...@gmail.com

unread,
Apr 5, 2019, 1:53:40 PM4/5/19
to Firebase Google Group
Thanks for the reply.

In the primer, it talks about using configurations for an application. In my case, I am trying to use AngularFire in a library, where there is no environment or configuration concept that I can see.

I would like to stress that I am trying to use AngularFire in library, and need to dynamically change the environment.



On Wednesday, April 3, 2019 at 11:17:06 AM UTC-7, Kato Richardson wrote:
I think you just use --configuration instead? See this primer.

☼, Kato

To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d581d322-7b4e-4c93-bfa2-8e186cec0b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ty.sh...@gmail.com

unread,
Apr 5, 2019, 1:53:40 PM4/5/19
to Firebase Google Group
I think what I'm missing is the HOW, on how to pass information from an application to a library.

I think this code is a key to my understanding but I'm not quite sure how it works, I found it here https://github.com/angular/angularfire2/blob/53ad0d8c73fbad785787d530f7ef0635e2422406/src/core/firebase.app.module.ts 

How do I pass a environment to a library?

export class AngularFireModule {
static initializeApp(options: FirebaseOptions, nameOrConfig?: string | FirebaseAppConfig) {
return {
ngModule: AngularFireModule,
providers: [
{ provide: FirebaseOptionsToken, useValue: options },
{ provide: FirebaseNameOrConfigToken, useValue: nameOrConfig }
]
}
}

On Wednesday, April 3, 2019 at 11:17:06 AM UTC-7, Kato Richardson wrote:
I think you just use --configuration instead? See this primer.

☼, Kato

To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d581d322-7b4e-4c93-bfa2-8e186cec0b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

YAM exchange

unread,
Apr 5, 2019, 6:43:03 PM4/5/19
to fireba...@googlegroups.com
Try the stackblitz IDE that is recommend on the firebase site.
It will allow you to connect to your Firebase instances with 1 easy click.


Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages