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,4 +1,3 @@
import { IDisposable } from "@coder/disposable";
import { Emitter } from "@coder/events";
import "./dialog.scss";
@@ -27,19 +26,16 @@ export enum IKey {
}
export class Dialog {
private options: IDialogOptions;
private overlay: HTMLElement;
private readonly overlay: HTMLElement;
private cachedActiveElement: HTMLElement | undefined;
private input: HTMLInputElement | undefined;
private actionEmitter: Emitter<IDialogAction>;
private errors: HTMLElement;
private buttons: HTMLElement[] | undefined;
public constructor(options: IDialogOptions) {
this.options = options;
this.actionEmitter = new Emitter();
private actionEmitter = new Emitter<IDialogAction>();
public onAction = this.actionEmitter.event;
public constructor(private readonly options: IDialogOptions) {
const msgBox = document.createElement("div");
msgBox.classList.add("msgbox");
@@ -108,13 +104,6 @@ export class Dialog {
});
}
/**
* Register a function to be called when the user performs an action.
*/
public onAction(callback: (action: IDialogAction) => void): IDisposable {
return this.actionEmitter.event(callback);
}
/**
* Input value if this dialog has an input.
*/