Skip to content

Commit eeebca8

Browse files
committed
Use SchedulerService instead of setInterval
SchedulerService internally implements setInterval, setTimeout functions to run outside of angular. This is required for protractor tests.
1 parent be27275 commit eeebca8

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

ui/src/main/webapp/src/app/executions/executions-list.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild} from "@angular/core";
1+
import {Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild} from "@angular/core";
22
import {WindupService} from "../services/windup.service";
33
import {MigrationProject, WindupExecution} from "../generated/windup-services";
44
import {NotificationService} from "../core/notification/notification.service";
@@ -8,6 +8,7 @@ import {MigrationProjectService} from "../project/migration-project.service";
88
import {WindupExecutionService} from "../services/windup-execution.service";
99
import {ConfirmationModalComponent} from "../shared/dialog/confirmation-modal.component";
1010
import {AbstractComponent} from "../shared/AbstractComponent";
11+
import {SchedulerService} from "../shared/scheduler.service";
1112

1213
@Component({
1314
selector: 'wu-executions-list',
@@ -53,7 +54,9 @@ export class ExecutionsListComponent extends AbstractComponent implements OnInit
5354
private _windupService: WindupService,
5455
private _notificationService: NotificationService,
5556
private _sortingService: SortingService<WindupExecution>,
56-
private _projectService: MigrationProjectService
57+
private _projectService: MigrationProjectService,
58+
private _schedulerService: SchedulerService,
59+
private _zone: NgZone
5760
) {
5861
super();
5962
this.element = _elementRef.nativeElement;
@@ -72,14 +75,17 @@ export class ExecutionsListComponent extends AbstractComponent implements OnInit
7275
this.doDeleteExecution(execution);
7376
});
7477

75-
this.currentTimeTimer = <any> setInterval(() => {
76-
this.currentTime = new Date().getTime();
78+
this.currentTimeTimer = this._schedulerService.setInterval(() => {
79+
this._zone.run(() => {
80+
this.currentTime = new Date().getTime();
81+
});
7782
}, 5000);
7883
}
7984

8085
ngOnDestroy(): void {
81-
if (this.currentTimeTimer)
82-
clearInterval(this.currentTimeTimer);
86+
if (this.currentTimeTimer) {
87+
this._schedulerService.clearInterval(this.currentTimeTimer);
88+
}
8389
}
8490

8591
@Input()

0 commit comments

Comments
 (0)