Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AsapAction.js 1023B

123456789101112131415161718192021222324252627
  1. import { Immediate } from '../util/Immediate';
  2. import { AsyncAction } from './AsyncAction';
  3. export class AsapAction extends AsyncAction {
  4. constructor(scheduler, work) {
  5. super(scheduler, work);
  6. this.scheduler = scheduler;
  7. this.work = work;
  8. }
  9. requestAsyncId(scheduler, id, delay = 0) {
  10. if (delay !== null && delay > 0) {
  11. return super.requestAsyncId(scheduler, id, delay);
  12. }
  13. scheduler.actions.push(this);
  14. return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
  15. }
  16. recycleAsyncId(scheduler, id, delay = 0) {
  17. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  18. return super.recycleAsyncId(scheduler, id, delay);
  19. }
  20. if (scheduler.actions.length === 0) {
  21. Immediate.clearImmediate(id);
  22. scheduler.scheduled = undefined;
  23. }
  24. return undefined;
  25. }
  26. }
  27. //# sourceMappingURL=AsapAction.js.map