Sign in

canrd-outside / order-erp-front · Files

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Builds 0
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 1
  • Labels
  • Wiki
  • order-erp-front
  • src
  • utils
  • scrollWaiter.ts
  • initial commit
    2f6253cf
    陈文彬 authored
    2020-09-28 20:19:10 +0800  
    Browse Dir »
scrollWaiter.ts 412 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
class ScrollQueue {
  private resolve: (() => void) | null = null;
  private promise: Promise<any> | null = null;

  add() {
    this.promise = new Promise((resolve) => {
      this.resolve = resolve;
    });
  }

  flush() {
    this.resolve && this.resolve();
    this.resolve = null;
    this.promise = null;
  }

  async wait() {
    await this.promise;
  }
}

export const scrollWaiter = new ScrollQueue();