Some cleanup

- Use whateverEmitter.event for the onWhatever methods.
- Add readonly to a bunch of things.
- Remove some redundancy in types.
- Move initializations out of the constructor and into the declarations
  where it was reasonable to do so.
- Disable a few no-any violations.
This commit is contained in:
Asher
2019-02-06 11:53:23 -06:00
parent ddf96077a3
commit 588da0443c
16 changed files with 98 additions and 164 deletions

View File

@@ -1,6 +1,5 @@
import { Event } from "@coder/events";
import { field, logger, time, Time } from "@coder/logger";
import { InitData, ISharedProcessData } from "@coder/protocol";
import { ISharedProcessData } from "@coder/protocol";
import { retry } from "./retry";
import { upload } from "./upload";
import { client } from "./fill/client";
@@ -24,14 +23,16 @@ export abstract class IdeClient {
private readonly tasks = <string[]>[];
private finishedTaskCount = 0;
private readonly loadTime: Time;
private readonly sharedProcessDataPromise: Promise<ISharedProcessData>;
public readonly initData = client.initData;
public readonly sharedProcessData: Promise<ISharedProcessData>;
public readonly onSharedProcessActive = client.onSharedProcessActive;
public constructor() {
logger.info("Loading IDE");
this.loadTime = time(2500);
this.sharedProcessDataPromise = new Promise((resolve): void => {
this.sharedProcessData = new Promise((resolve): void => {
client.onSharedProcessActive(resolve);
});
@@ -96,27 +97,6 @@ export abstract class IdeClient {
}
}
/**
* A promise that resolves with initialization data.
*/
public get initData(): Promise<InitData> {
return client.initData;
}
/**
* An event that fires every time the shared process (re-)starts.
*/
public get onSharedProcessActive(): Event<ISharedProcessData> {
return client.onSharedProcessActive;
}
/**
* A promise that resolves with *initial* shared process data.
*/
public get sharedProcessData(): Promise<ISharedProcessData> {
return this.sharedProcessDataPromise;
}
public set notificationService(service: INotificationService) {
this.retry.notificationService = service;
this.upload.notificationService = service;