switchmap stackoverflow code example
Example: switchmap stackoverflow
#switchMap cancels the previous inner observable when the outer observable emits.
#For example
Observable.fromEvent(inputEl, 'keydown') // outer observable
.switchMap(event => {
let value = event.value;
return this.myXYZService.search(value); // inner observable
})
.subscribe(res => {
// some code
});