Open Methodician opened 6 years ago
I tried something like this and it seems to work:
listItemsRef(parent){ return firebase.database().ref(/${parent}/${parent}-slugs); }
/${parent}/${parent}-slugs
subjectFromRef(ref: firebase.database.Reference): BehaviorSubject{ const subject = new BehaviorSubject(null); ref.on('value', snapshot => { const val = snapshot.val(); subject.next(val); }) return subject; }
In component:
const ref = this.featuredService.listItemsRef(this.parent); this.featuredService.subjectFromRef(ref).subscribe(res => console.log('RESULT', res));
I tried something like this and it seems to work:
listItemsRef(parent){ return firebase.database().ref(
/${parent}/${parent}-slugs
); }subjectFromRef(ref: firebase.database.Reference): BehaviorSubject{
const subject = new BehaviorSubject(null);
ref.on('value', snapshot => {
const val = snapshot.val();
subject.next(val);
})
return subject;
}
In component:
const ref = this.featuredService.listItemsRef(this.parent); this.featuredService.subjectFromRef(ref).subscribe(res => console.log('RESULT', res));