Currently, I am in the process of upgrading an application from Angular 4 to Angular 5. The following code snippet is found within a service:
loadRefData(): Observable<RefData> {
return this.participant$.switchMap((role) => {
return this.http.get(`${this.API_URL}/${role}/participantGroups/refdata`)
.map(refData => refData as RefData);
});
Due to the fact that Angular 5 mandates a minimum requirement of RxJS 5.5.2, I am in the process of migrating it to utilize lettable operators with the .pipe()
operator.
I initially attempted the following modification:
loadRefData(): Observable<RefData> {
return this.participant$.switchMap((role) => {
return this.http.get(`${this.API_URL}/${role}/participantGroups/refdata`)
.pipe(
map(refData => refData as RefData);
);
});
Unfortunately, this resulted in the error message saying
TypeError: this.participant$.switchMap is not a function
. Surprisingly, no compilation errors were detected by the typescript compiler.
The type of this.participant$
is Observable<string>
, and theoretically, I should be able to execute a switchMap
operation on it.
What could be the issue here?
For additional context, I realized that this.participant$
, which is assigned values from ngrx\store.select
, has a type of Store<string>
.