Skip to content

flushJob方法为什么不在finally里面调用jobQueue.clear()清空队列? #218

@zhaoyunyes

Description

@zhaoyunyes
/** 刷新(执行)任务队列 */
function flushJob() {
  if (isFlushing) return;
  isFlushing = true;
  p.then(() => {
    jobQueue.forEach((job: any) => job());
  }).finally(() => {
    isFlushing = false;
    // 清空队列
    jobQueue.clear();
  });
}

如果不清空,看起来会在下一个任务周期中数据变化后不需要执行的job再次执行(某些条件下,job应该被cleanup并且不需要再执行了)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions