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:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user