私はRXJSデバウンスを使用した簡単な検索方法を持っていますサービスでエラーが発生した後に変更メソッドが呼び出されない角度2
このようにします。
this.searchTerm.valueChanges
.debounceTime(this._debounceDelay, this._scheduler)
.distinctUntilChanged()
.filter(this.filterForBlank.bind(this))
.filter(this.filterForLength.bind(this))
.switchMap(term => this.searchService.serchBy(term))
.subscribe((data) => {
// do something
}, (err) => {
// show error on UI
});
private filterForLength(term: string) {
return (term.trim().length > 2);
}
private filterForBlank(term: string) {
if (isEmpty(term)) {
return false;
}
return true;
}
などですが、エラーがある場合、たとえば、URLを間違ったものに変更しました。この変更機能は再びヒットしません。値を変更しても
私はエラーがある場合、私は観察可能なものを殺す必要があると思う。しかし、これを達成する方法はまったくありません。
それはキャッチするつもりですが、値の変更後にAPIを呼び出さない –