Methodician/flight.run

Implement automatic way to work again with observables without AngularFire2

Opened this issue · 0 comments

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));