Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

AnimationFrameScheduler.ts 756B

12345678910111213141516171819202122232425262728293031
  1. import { AsyncAction } from './AsyncAction';
  2. import { AsyncScheduler } from './AsyncScheduler';
  3. export class AnimationFrameScheduler extends AsyncScheduler {
  4. public flush(action?: AsyncAction<any>): void {
  5. this.active = true;
  6. this.scheduled = undefined;
  7. const {actions} = this;
  8. let error: any;
  9. let index: number = -1;
  10. let count: number = actions.length;
  11. action = action || actions.shift();
  12. do {
  13. if (error = action.execute(action.state, action.delay)) {
  14. break;
  15. }
  16. } while (++index < count && (action = actions.shift()));
  17. this.active = false;
  18. if (error) {
  19. while (++index < count && (action = actions.shift())) {
  20. action.unsubscribe();
  21. }
  22. throw error;
  23. }
  24. }
  25. }