【发布时间】:2021-10-26 06:24:15
【问题描述】:
我得到的错误是
Argument of type '(data: Object) => Observable<Object> | undefined' is not assignable to parameter of type '(value: Object, index: number) => ObservableInput<any>'.
Type 'Observable<Object> | undefined' is not assignable to type 'ObservableInput<any>'.
Type 'undefined' is not assignable to type 'ObservableInput<any>'
以下是我遇到问题的代码
this.AService.aFunction(this.parms).pipe(take(1) ,switchMap( data => {
if(data){
return this.aService.bDomain(this.parms)
}
})
).subscribe(result =>{
if(result){
open success modal
} else {
open fail modal
}
})
【问题讨论】:
-
... 嗯,有点意思:“好的,在 SwitchMap 内部,您将处理
if条件,继续管道,.. 但是else怎么样(以防@987654325 @ 语句原来是false) ..? ..(我的意思是,至少返回of(null)smt ...) -
@Vovan_Super 感谢您的帮助。明白了。
标签: angular typescript rxjs