Skip to main content
Module

x/enzastdlib/events/eventtarget.ts>TypedEventTarget#dispatchEvent

enzastdlib is a set of TypeScript modules that follow a common design API philosophy aiming at sane defaults and ease-of-use targeting the Deno TypeScript runtime.
Latest
method TypedEventTarget.prototype.dispatchEvent
import { TypedEventTarget } from "https://deno.land/x/enzastdlib@v0.0.4/events/eventtarget.ts";

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

Examples

Example 1

import { TypedEventTarget } from 'https://deno.land/x/enzastdlib/events/mod.ts';

const event_target = new TypedEventTarget<
    { myEvent: CustomEvent<{ myValue: number }> }
>();

const event = new CustomEvent('myEvent', { detail: { myValue: 1 } });

event_target.addEventListener('myEvent', console.log);

event_target.dispatchEvent(event); // `{ myValue: 1 }`

Type Parameters

Event extends EventRecord[keyof EventRecord]

Returns

boolean