Я получаю 2 синтаксические ошибки со следующим кодом:
handleTypeahead = (text$: Observable<string>) => {
text$.pipe(
distinctUntilChanged(),
debounceTime(500),
.tap((term) => this.target = text$),
// tap((term) => console.log("handleTypeahead", term)),
// tap((term) => this.onTypeahead.emit(term)),
/*map((term: string) => [])*/
/*map((term: string) => term === '' ? [] : this.data)*/
.switchMap(term => term === '' ? [] : this.data)
).subscribe((term) => this.onTypeahead.emit(term))
}
1) по debounceTime
- «ожидается выражение».
2) по .subscribe
- «Неразрешенная функция или метод подписки ()»
Я пробовал это без оператора pipe
, но также имел синтаксические ошибки, очень плохо знакомые с RXJS, но у меня было много проблем с этим.
v2:
handleTypeahead = (text$: Observable<string>) => {
text$
distinctUntilChanged(),
debounceTime(500),
.tap((term) => this.target = text$),
// tap((term) => console.log("handleTypeahead", term)),
// tap((term) => this.onTypeahead.emit(term)),
/*map((term: string) => [])*/
/*map((term: string) => term === '' ? [] : this.data)*/
.switchMap(term => term === '' ? [] : this.data)
.subscribe((term) => this.onTypeahead.emit(term))
}
Здесь я получаю только номер ошибки # 2, любая помощь приветствуется (конечно, будет выше)