I'm trying to exit the Observable stream when it takes longer than 3 seconds. The problem is that when I copy and paste the same value a couple of times, distinctUntilChanged
operator does not let the input stream go passed. So I want to time out if no string stream comes passed it. Here is what I have.
import { Subject } from "rxjs/Subject";
import "rxjs/add/operator/filter";
import "rxjs/add/operator/debounceTime";
import "rxjs/add/operator/distinctUntilChanged";
import "rxjs/add/operator/switchMap";
import "rxjs/add/operator/timeout";
this._searchSubject
.filter(val => val.length > 0)
.debounceTime(500)
.distinctUntilChanged()
.timeout(3000)
.switchMap(userSearchInput => {
...api call that returns Promise
})
.subscribe(searchResults => {
...do stuff with the result
});