I have a component that queries an angularfire document within a service. The below works, because I copied and pasted it from another function I was using that required the activatedRoute
check. In this instance I don't need the activated route check.
However, I'm unsure of the syntax to remove that particular check and still have the same outcome of querying the database, getting the result in return and subscribing to it.
Component.ts
testQuery(id: string) {
this._subscription = this._activatedRoute.params.pipe(
switchMap(params => {
return this.service.getInfo(id);
})
).subscribe(details => {
// Subscription stuff and form patchValue and behaviorSubject updates
})
}
Service.ts
getInfo(id: string): Observable<any[]> {
return this.afs.doc<any>(`collection/${id}`).valueChanges().pipe(shareReplay());
}
Simply remove that piece of code and the pipe(switchMap...
which is no longer needed.
testQuery(id: string) {
this._subscription = this.service.getInfo(id).subscribe(details => {
// Subscription stuff and form patchValue and behaviorSubject updates
});
}