This file contains hidden or 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
interface IKeyEventsListeners { | |
keyup: { [componentId: string]: (event: KeyboardEvent) => void }; | |
keydown: { [componentId: string]: (event: KeyboardEvent) => void }; | |
} | |
export interface IKeySubscription { | |
unsubscribe: () => void; | |
} | |
const keyListener = (<T extends keyof IKeyEventsListeners>() => { |
This file contains hidden or 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
type TEvent = 'player-icu'; | |
type EventCallback<T> = (data: T) => void; | |
class EventPublisher { | |
// Subscription Record<EventName, Record<SubscriberId, callback>> | |
private subscriptions: Record< | |
string, | |
Record<string, EventCallback<unknown>> | |
> = {}; |
OlderNewer