我在下面的代码中发现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)by debounceTime -“期望的表达式”。2)by .subscribe -“未解析的函数或方法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))
}在这里我得到了just error num#2任何感谢的帮助(当然会向上投票)
发布于 2019-06-05 17:51:37
在.tap和.switchMap正常工作之前删除这些点:
text$.pipe(
distinctUntilChanged(),
debounceTime(500),
tap(term => this.target = text$),
switchMap(term => term === '' ? [] : this.data)
).subscribe(term => this.onTypeahead.emit(term));https://stackoverflow.com/questions/56457998
复制相似问题