SOURCE

console 命令行工具 X clear

                    
>
console
const { from, defer, interval } = rxjs;
const { take, mergeAll, retry, delay, retryWhen } = rxjs.operators;

// 假设移除文件的promise操作
function remove(path) {
  return new Promise((resolve, reject) => {
    console.log('remove'+ path);
    const willSuccess = Math.random() > 0.5;
    willSuccess && resolve(path) || reject(path);
  })
}

// 假设要删除的文件数组
const fileList = 'abcdefg'.split('');

// 用户自定义清除文件函数
function cleanFiles(arr) {
  const obserbales = arr.map(v => defer(() => remove(v)).pipe(
    retryWhen(errors => errors.pipe(delay(1000),take(3)))
  ));
  return from(obserbales).pipe(
     mergeAll()
  );
}

cleanFiles(fileList).subscribe(console.log, console.error);
<h3>rxjs promise重试</h3>

<quate>
<a targe="_blank" href="https://stackoverflow.com/questions/44979131/rxjs-retry-with-delay-function">参考文档</a>
</quate>

本项目引用的自定义外部资源