Last change
on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
746 bytes
|
Line | |
---|
1 | import { AsyncAction } from './AsyncAction';
|
---|
2 | import { AsyncScheduler } from './AsyncScheduler';
|
---|
3 |
|
---|
4 | export class AsapScheduler extends AsyncScheduler {
|
---|
5 | public flush(action?: AsyncAction<any>): void {
|
---|
6 |
|
---|
7 | this.active = true;
|
---|
8 | this.scheduled = undefined;
|
---|
9 |
|
---|
10 | const {actions} = this;
|
---|
11 | let error: any;
|
---|
12 | let index: number = -1;
|
---|
13 | let count: number = actions.length;
|
---|
14 | action = action || actions.shift();
|
---|
15 |
|
---|
16 | do {
|
---|
17 | if (error = action.execute(action.state, action.delay)) {
|
---|
18 | break;
|
---|
19 | }
|
---|
20 | } while (++index < count && (action = actions.shift()));
|
---|
21 |
|
---|
22 | this.active = false;
|
---|
23 |
|
---|
24 | if (error) {
|
---|
25 | while (++index < count && (action = actions.shift())) {
|
---|
26 | action.unsubscribe();
|
---|
27 | }
|
---|
28 | throw error;
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.