我有N个网址,我不知道它的数量(直到到达停止状态)
这是我的用法:
from(observableUrls)
.pipe(
mergeMap(url => callHttpService(url) , 4),
retryWhen(
// what is the algorithm or suggestion how to?
)
).subscribe( result => {
// doing some stuff with my results
});
如果某些URL失败,怎么执行重试而不重新运行的算法或建议是什么。
StackBlitz: https://angular-w5t15m.stackblitz.io
答案 0 :(得分:0)
您应在单个retryWhen
的可观察管道中使用callHttpService(url)
,如下所示:
from(observableUrls)
.pipe(
mergeMap(url => callHttpService(url)
.pipe(
retryWhen(
// use your retryWhen logic here
)
) , 4)
).subscribe( result => {
// doing some stuff with my results
});
在内部Observable(retryWhen
)的Observable管道中包含callHttpService(url)
将确保根据retryWhen
逻辑仅重试该可观察项。
希望对您有所帮助。