MultistepOperation: Don't need 'completed', just use requestId === undefined (#17173)

* MultistepOperation: Don't need 'completed', just use `requestId === undefined`

* Check for `requestId !== undefined`
This commit is contained in:
Andy 2017-08-08 10:49:49 -07:00 committed by GitHub
parent ceae613e4c
commit e1802f4966

View File

@ -163,26 +163,22 @@ namespace ts.server {
* Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed.
*/
class MultistepOperation implements NextStep {
private requestId: number;
private requestId: number | undefined;
private timerHandle: any;
private immediateId: any;
private completed = true;
private immediateId: number | undefined;
constructor(private readonly operationHost: MultistepOperationHost) {}
public startNew(action: (next: NextStep) => void) {
this.complete();
this.requestId = this.operationHost.getCurrentRequestId();
this.completed = false;
this.executeAction(action);
}
private complete() {
if (!this.completed) {
if (this.requestId) {
this.operationHost.sendRequestCompletedEvent(this.requestId);
}
this.completed = true;
if (this.requestId !== undefined) {
this.operationHost.sendRequestCompletedEvent(this.requestId);
this.requestId = undefined;
}
this.setTimerHandle(undefined);
this.setImmediateId(undefined);