Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/khrj/typed-event-target

Strictly typed EventTarget for Deno and the Browser
https://github.com/khrj/typed-event-target

browser deno emit event eventtarget strict types typescript

Last synced: 4 days ago
JSON representation

Strictly typed EventTarget for Deno and the Browser

Awesome Lists containing this project

README

        


typed_event_target illustration

Typed Event Target



Strictly typed EventTarget for Deno and the Browser



build status
language
code size
issues
license
version



View on deno.land








## Usage

```ts
import { TypedCustomEvent, TypedEventTarget } from 'https://deno.land/x/[email protected]/mod.ts'

type Events = {
Hi: string
Hello: boolean
}

const emitter = new TypedEventTarget()

emitter.addEventListener("Hi", (value) => {
console.log(value.detail) // "Hello"
})

emitter.dispatchEvent(new TypedCustomEvent("Hi", { detail: "Hello" }))
```

## API

Same as [non-strict EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), however a parameter _must_ be passed to `TypedCustomEvent`.

## Supporters

[![Stargazers repo roster for @khrj/typed-event-target](https://reporoster.com/stars/khrj/typed-event-target)](https://github.com/khrj/typed-event-target/stargazers)

[![Forkers repo roster for @khrj/typed-event-target](https://reporoster.com/forks/khrj/typed-event-target)](https://github.com/khrj/typed-event-target/network/members)

## Related

- [Deno modules](https://github.com/khrj/deno-modules)