1.0.1 • Published 11 months ago

com.hydroper.typedeventtarget v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 months ago

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 Event interface, thus in the previous program CustomEvent is used; if there was no data, it could have just been Event itself.

1.0.1

11 months ago

1.0.0

11 months ago