RXJS TAP操作员支持异步函数?
我的示例代码是
this.urls$.pipe(
map(async (val) => {
return await http.get(url);
}),
tap(async (val) => {
const res = await val.res;
console.log(res);
return ture;
})
).subscribe();
,但我收到了一条ESLINT消息。
预期返回空隙。
在函数辩论中返回的承诺,可以
my example code is
this.urls$.pipe(
map(async (val) => {
return await http.get(url);
}),
tap(async (val) => {
const res = await val.res;
console.log(res);
return ture;
})
).subscribe();
but i got a eslint message.
Promise returned in function argument where a void return was expected.eslint
how can i avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将承诺转换为可观察的,并使用
switchmap
(或simelar)运算符,而不是等待地图中的承诺。Instead of awaiting a promise within map, you could convert the promise to an observable and use
switchMap
(or simelar) operator.