Skip to content

Commit

Permalink
replace event emitter with typed emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Aug 21, 2024
1 parent 0fe133a commit 939ef79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"lint-staged": "^15.2.8",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"typed-emitter": "^2.1.0",
"typescript": "^5.5.4"
},
"author": "Torus Labs",
Expand Down
12 changes: 7 additions & 5 deletions src/utils/PopupHandler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { EventEmitter } from "eventemitter3";
import { EventEmitter } from "events";
import type { default as TypedEmitter } from "typed-emitter";

import { getPopupFeatures } from "./helpers";

export interface PopupHandlerEvents {
close: void;
}
export type PopupHandlerEvents = {
close: () => void;
};

class PopupHandler extends EventEmitter<PopupHandlerEvents> {
class PopupHandler extends (EventEmitter as new () => TypedEmitter<PopupHandlerEvents>) {
url: URL;

target: string;
Expand All @@ -22,6 +23,7 @@ class PopupHandler extends EventEmitter<PopupHandlerEvents> {
timeout: number;

constructor({ url, target, features, timeout = 30000 }: { url: URL; target?: string; features?: string; timeout?: number }) {
// eslint-disable-next-line constructor-super
super();
this.url = url;
this.target = target || "_blank";
Expand Down

0 comments on commit 939ef79

Please sign in to comment.