Skip to main content Link Search Menu Expand Document (external link)

EventTarget overview

Low-level Effect wrappers for EventTarget APIs.

Added in v8.19.0


Table of contents


events

AddEventListenerOptions (interface)

Add an event listener to an EventTarget

Signature

export interface AddEventListenerOptions<T extends EventTarget, EventName extends string, R2>
  extends globalThis.AddEventListenerOptions {
  readonly eventName: EventName

  readonly handler: (
    event: EventWithCurrentTarget<T, EventName extends keyof DefaultEventMap<T> ? DefaultEventMap<T>[EventName] : Event>
  ) => Effect.Effect<unknown, never, R2>
}

Added in v8.19.0

EventWithCurrentTarget (type alias)

Helper for creating an Event that has the currentTarget property set.

Signature

export type EventWithCurrentTarget<T, Ev = Event> = Ev & { currentTarget: T }

Added in v8.19.0

EventWithTarget (type alias)

Helper for creating an Event that has the target property set.

Signature

export type EventWithTarget<T, Ev = Event> = Ev & { target: T }

Added in v8.19.0

addEventListener

Add an event listener to an EventTarget

Signature

export declare const addEventListener: {
  <T extends EventTarget, EventName extends string, R = never>(
    options: AddEventListenerOptions<T, EventName, R>
  ): (target: T) => Effect.Effect<void, never, R | Scope.Scope>
  <T extends EventTarget, EventName extends string, R = never>(
    target: T,
    options: AddEventListenerOptions<T, EventName, R>
  ): Effect.Effect<void, never, R | Scope.Scope>
}

Added in v8.19.0

dispatchEvent

Dispatch an event from an EventTarget

Signature

export declare const dispatchEvent: {
  <T extends EventTarget, EventName extends keyof DefaultEventMap<T>>(
    event: EventName,
    options?: EventInit
  ): (target: T) => Effect.Effect<boolean, never, GlobalThis>
  <T extends EventTarget, EventName extends keyof DefaultEventMap<T>>(
    target: T,
    event: EventName,
    options?: EventInit
  ): Effect.Effect<boolean, never, GlobalThis>
}

Added in v8.19.0

isUsingKeyModifier

Check to see if a key modifier is being used

Signature

export declare function isUsingKeyModifier(event: KeyboardEvent | MouseEvent): boolean

Added in v8.19.0