1.0.1 • Published 1 year ago
com.hydroper.typedeventtarget v1.0.1
Typed event target
Easily define event types for an EventTarget, crediting to this article.
Getting started
The following program defines play and stop events.
import { TypedEventTarget } from "com.hydroper.typedeventtarget";
class MediaPlayer extends (EventTarget as TypedEventTarget<{
play: CustomEvent<MediaPlayerEvent>;
stop: CustomEvent<MediaPlayerEvent>;
}>) {}Note that event types must implement the
Eventinterface, thus in the previous programCustomEventis used; if there was no data, it could have just beenEventitself.