Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 months ago
JSON representation
Strictly typed EventTarget for Deno and the Browser
- Host: GitHub
- URL: https://github.com/khrj/typed-event-target
- Owner: khrj
- License: mit
- Created: 2021-02-18T13:36:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-26T10:59:37.000Z (over 2 years ago)
- Last Synced: 2024-10-09T00:22:42.622Z (4 months ago)
- Topics: browser, deno, emit, event, eventtarget, strict, types, typescript
- Language: TypeScript
- Homepage:
- Size: 63.5 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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)