Skip to content

Commit

Permalink
refactor(BaseEvent): update interface (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimshins authored Oct 14, 2024
1 parent c242deb commit 8aa0688
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/events/BaseEvent.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
type Config<T> = EventInit & {
details: T;
};

abstract class BaseEvent<T> extends Event {
private _details?: T;
private _details: T;

public get details(): T | undefined {
public get details(): T {
return this._details;
}

constructor(name: string, eventInit?: EventInit & { details?: T }) {
const { details, ...init } = eventInit ?? {};
constructor(name: string, config: Config<T>) {
const { details, ...init } = config;

super(name, init);

Expand Down

0 comments on commit 8aa0688

Please sign in to comment.