mirror of
https://gitcode.com/gh_mirrors/vue/vue-vben-admin
synced 2026-05-18 17:27:46 +00:00
23 lines
412 B
TypeScript
23 lines
412 B
TypeScript
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();
|