Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement automatic way to work again with observables without AngularFire2 #98

Open
Methodician opened this issue Sep 13, 2018 · 0 comments
Assignees

Comments

@Methodician
Copy link
Owner

Methodician commented Sep 13, 2018

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

@Methodician Methodician self-assigned this Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant