【发布时间】:2018-02-19 23:04:38
【问题描述】:
使用下面的代码,我每 500 毫秒得到一个值,我取其中的 10 个。
现在我想过滤掉无效值,但我想调用的函数是异步的(但发生得很快),我不知道如何在过滤器运算符中做到这一点。
this.subscription = this.input.getStream()
.throttleTime(500)
.filter(value => {
// I want to filter out invalid values
// but the function I want to call here is async
})
.take(10) // and get 10 valid ones
.subscribe(value => {
this.values.push(value)
})
注意:我希望过滤器在 时间限制之后发生。
【问题讨论】:
标签: javascript asynchronous rxjs observable