У меня есть определение behaviorSubject:
measurementSearchChange$ = new BehaviorSubject('');
this.measurementSearchChange$
.asObservable()
.pipe(debounceTime(500))
.pipe(
switchMap((keyword: string) =>
this.warningService.getInfluxdbQuery(
this.selectedMonitorOption,
'measurement',
{ search_name: keyword }
)
)
)
.subscribe((data: any) => {
this.measurementOptions = data;
this.isLoading = false;
});
когда какое-то действие будет делать это:
this.measurementSearchChange$.next(keyword);
сейчас он работает хорошо, но я хочу добавить switchMap и заархивировать их, чтобы я мог подписаться на два разных данных, например :
this.measurementSearchChange$
.asObservable()
.pipe(debounceTime(500))
.pipe(
switchMap((keyword: string) =>
this.warningService.getInfluxdbQuery(
this.selectedMonitorOption,
'measurement',
{ search_name: keyword }
)
// another
this.warningService.getInfluxdbQuery2(
this.selectedMonitorOption,
'measurement2',
{ search_name: keyword }
)
)
)
.subscribe((data1: any, data2: any) => {
this.measurementOptions = data;
this.isLoading = false;
});
так как это сделать? любая помощь ценится