How to reference firebase adapter from another file using ember-cli?

Hi, I’m on ember-cli 0.46 and Emberfire. How would I access the ```firebaseproperty from, say, myinitializer/auth` file? I’d like to avoid defining a reference to my firebase twice.

My application adapter looks like this:

import DS from 'ember-data';
import ENV from '../config/environment';

export default DS.FirebaseAdapter.extend({
	firebase: new window.Firebase('https://' + ENV.firebase_instance + '.firebaseio.com')
});

What you are already doing is fine. The Firebase code will take care of unifying the connections in a single connection (as per the docs).

Stefan Penner has a sample project running on ember-fire that uses ember-cli.

He defines the application adapter thusly:

export default DS.FirebaseAdapter.extend({
  firebase: new window.Firebase('https://' + ENV.firebase_instance + '.firebaseio.com')
});

And then uses this.store to send backend requests through the adapter to Firebase.

Does that not help?

Thank you both. Perhaps I should clarify. My issue is that I’m defining the Firebase instance more than once, shouldn’t I be able to access the firebase property from other files somehow to avoid defining it twice? Even if Firebase unifies the connections.

The code I posted above already works, I’d just like to avoid duplicating a line of code :slight_smile:

You should be able to define an initializer that injects the firebase instance on all controllers and routes, exactly as EmberData is doing with the store.

Actually, no you shouldn’t, not in all cases. For example, you might want to listen to the authentication status if you’re using FirebaseSimpleLogin:

this.authRef = new window.Firebase( firebase + '/.info/authenticated' )

And there might be other URLs where you want to access Firebase specifics, can’t recall any others off hand though.