📜  switchmap stackoverflow - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:26.499000             🧑  作者: Mango

代码示例1
#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
    });