-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- EventEmitter now has proper inferencing with a type parameter that takes in a record of events. - Fixed a problem with the silly `mitt` library not exporting the default function correctly, causing props to be `any`. - Fixed internal on and off props not being readonly. - Updated Squaremap GPS to use its own types instead of Dynmap ones.
- Loading branch information
Showing
3 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
import mitt from 'mitt' | ||
import type { EventType } from 'mitt' | ||
|
||
export default class Mitt { | ||
_on: any | ||
export default class Emitter<Events extends Record<EventType, unknown>> { | ||
private _on | ||
get on() { | ||
return this._on | ||
} | ||
|
||
_off: any | ||
|
||
private _off | ||
get off() { | ||
return this._off | ||
} | ||
|
||
protected emit: any | ||
protected emit | ||
|
||
constructor() { | ||
//@ts-ignore | ||
const emitter = mitt() | ||
|
||
Object.keys(emitter).forEach(() => { | ||
this._on = emitter['on'] | ||
this._off = emitter['off'] | ||
this.emit = emitter['emit'] | ||
}) | ||
const emitter = mitt.default<Events>() | ||
|
||
this._on = emitter.on | ||
this._off = emitter.off | ||
this.emit = emitter.emit | ||
} | ||
} |