-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Having to manually get a new FirebaseObservable from a child property is a bit cumbersome. While it's a best practice to denormalize your database, there will be some cases with nested data:
object: FirebaseObjectObservable<any>;
list: FirebaseListObservable<any>;
let object = this.af.database.object('/object');
let list = this.af.database.list('object/childlist');
What if we could reference this property and return it as it's own observable:
object: FirebaseObjectObservable<any>;
list: FirebaseListObservable<any>;
let object = this.af.database.object('/object');
let list = object.child('childlist');
We could have a distinction between returning the observable as FirebaseListObservable / FirebaseObjectObservable
object: FirebaseObjectObservable<any>;
let listObservable = object.childList('childlist');
let objectObservable = object.childObject('childlist');
With this we could pass a new Observables much easier. Suppose we get a FirebaseListObservablereference and want to get one of the childs and return it as a FirebaseObjectObservable. We'll do this by getting the $key value from the list item and using that to get the full URI for the resource:
let listObjectObservable = this.af.database.object('/list/' + listObject.$key);
Instead we could just get the list and use the new childObject() method:
list: FirebaseListObservable<any>;
object: FirebaseObjectObservable<any>;
let object = list.childObject(listObject.$key);
So basically the child() method would make it a bit quicker to get the property as a observable. I guess using the current object's firebaseref and amending to that would be a simple solution.
But are there any pitfalls performance wise or is there a fundamental problem with my thinking?
Perhaps there are better ways to do this.
In any case thanks for the great library: it makes it very easy to handle Firebase related tasks!