frontend/.pnpm-store/v3/files/f8/35d78f91bd36585d067c4afa81975491abfb315fa5f34ed5a7edee1fa981de682f4678644624d028f84345c2e55c9e39079f8d062e1067ede7e78e82b3c61f

32 lines
746 B
Plaintext

import { AsyncAction } from './AsyncAction';
import { AsyncScheduler } from './AsyncScheduler';
export class AsapScheduler extends AsyncScheduler {
public flush(action?: AsyncAction<any>): void {
this.active = true;
this.scheduled = undefined;
const {actions} = this;
let error: any;
let index: number = -1;
let count: number = actions.length;
action = action || actions.shift();
do {
if (error = action.execute(action.state, action.delay)) {
break;
}
} while (++index < count && (action = actions.shift()));
this.active = false;
if (error) {
while (++index < count && (action = actions.shift())) {
action.unsubscribe();
}
throw error;
}
}
}