element-vir - v26.14.0
    Preparing search index...

    Function defineTypedEvent

    • Define a stand-alone typed event that can be emitted and listened to inside of HTML templates.

      Make sure to use currying and call this function twice! (This is required by TypeScript's type parameter inference system.)

      Type Parameters

      • EventDetailGeneric

      Returns <EventTypeNameGeneric extends string>(
          eventType: NonEmptyString<EventTypeNameGeneric>,
      ) => DefinedTypedEvent<EventTypeNameGeneric, EventDetailGeneric>

      import {defineTypedEvent} from 'element-vir';

      const myCustomEvent = defineTypedEvent<number>()('my-custom-event');

      const myCustomEvent2 = defineTypedEvent<// the event's `.detail` type
      number>()(
      // the event's `.type` string
      'my-custom-event2',
      );