import { TypedCustomEvent, TypedEventTarget } from 'https://deno.land/x/typed_event_target@1.0.1/mod.ts'
type Events = {
Hi: string
Hello: boolean
}
const emitter = new TypedEventTarget<Events>()
emitter.addEventListener("Hi", (value) => {
console.log(value.detail) // "Hello"
})
emitter.dispatchEvent(new TypedCustomEvent("Hi", { detail: "Hello" }))
Same as non-strict EventTarget, however a parameter must be passed to TypedCustomEvent
.