【发布时间】:2018-09-19 20:23:57
【问题描述】:
我是 rxjs 和管道的新手 - 并试图理解为什么我会收到此打字稿错误:“Observable 类型的参数不能分配给参数 OperatorFunction”。有人可以向我解释一下吗?
意图是请求“Hello”,但在数据通过管道传输时将数据替换为“Bye”。
ngOnInit() {
this.getHello()
.pipe(this.getBye())
.subscribe(data => console.log(data))
}
getHello() {
return of("Hello")
}
getBye() {
return of ("Bye")
}
}
【问题讨论】:
-
你对
.pipe(this.getBye())这行有什么期望?看起来不合逻辑,这也是错误的根源 -
this.getHello().pipe(_ => this.getBye()) -
其中一个答案解决了您的问题吗?