tiny-typed-emitter
tiny-typed-emitter copied to clipboard
Provide also raw interface definition instead of just class
First, thanks for this helpful package @binier ! I used to manually declare onX(…) events to enforce typed events until I found it.
One thing I miss is a plain interface definition which I can inherit.
export interface ITypedEmitter<L extends ListenerSignature<L> = DefaultListener> {
addListener<U extends keyof L>( event: U, listener: L[U] ): this;
prependListener<U extends keyof L>( event: U, listener: L[U] ): this;
// etc.
}
export interface MyInterfaceWithEvents extends ITypedEmitter<MyEvents> {
// …
}
so users of the interface can also rely on typed events, not only users of the instance.