1.0.3 • Published 6 months ago

@hydroperx/event v1.0.3

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

Event

Easily define event types for an EventTarget. Credits to this article.

Getting started

The following program defines play and stop events.

import { TypedEventTarget } from "@hydroperx/event";

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.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago