Switching Firebase instance on the fly?

17 views
Skip to first unread message

Eric Walti

unread,
Apr 8, 2016, 11:37:32 PM4/8/16
to Firebase + EmberJS
Hi there, I was thinking of playing with some sort of revisioning in my Ember app by storing things in Firebase under a different tree. As such I was thinking of changing the FB _ref on the fly but have been unable to do so. I tried:
Ember.getOwner(this).lookup('adapter:application').reopen({ _ref: new Firebase(`url/revisions/${revisionNumber}`) })
But that didn't seem to swap where EF is hitting for data. 

Is there a better way to do this?

Thanks!

Tim Stirrat

unread,
May 11, 2016, 12:48:52 AM5/11/16
to Eric Walti, Firebase + EmberJS
Hi Eric,

When you .reopen() a class it modifies the object prototype, however _ref is a property directly on the adapter instance.

Instead, you want to modify the instantiated adapter:

const adapter = Ember.getOwner(this).lookup('adapter:application');
adapter._ref = new Firebase('https://...');

That should get you what you want :)

🔥 Tim

--
You received this message because you are subscribed to the Google Groups "Firebase + EmberJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-embe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages