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

EventHandler overview

Added in v1.0.0


Table of contents


utils

Context (type alias)

Signature

export type Context<T> = T extends EventHandler<infer _Ev, infer _E, infer R> ? R : never

Added in v1.0.0

Error (type alias)

Signature

export type Error<T> = T extends EventHandler<infer _Ev, infer E, infer _R> ? E : never

Added in v1.0.0

EventHandler (interface)

Signature

export interface EventHandler<Ev extends Event = Event, E = never, R = never> extends Placeholder<never, E, R> {
  readonly [EventHandlerTypeId]: EventHandlerTypeId
  readonly handler: (event: Ev) => Effect.Effect<unknown, E, R>
  readonly options: AddEventListenerOptions | undefined
}

Added in v1.0.0

EventHandlerTypeId

Signature

export declare const EventHandlerTypeId: typeof EventHandlerTypeId

Added in v1.0.0

EventHandlerTypeId (type alias)

Signature

export type EventHandlerTypeId = typeof EventHandlerTypeId

Added in v1.0.0

EventOf (type alias)

Signature

export type EventOf<T> = T extends EventHandler<infer Ev, infer _E, infer _R> ? Ev : never

Added in v1.0.0

EventOptions (type alias)

Signature

export type EventOptions = {
  readonly preventDefault?: boolean
  readonly stopPropagation?: boolean
  readonly stopImmediatePropagation?: boolean
}

Added in v1.0.0

keys

Signature

export declare function keys<Keys extends ReadonlyArray<string>>(...keys: Keys)

Added in v1.0.0

make

Signature

export declare function make<Ev extends Event, E = never, R = never>(
  handler: (event: Ev) => Effect.Effect<unknown, E, R>,
  options?: AddEventListenerOptions
): EventHandler<Ev, E, R>

Added in v1.0.0

preventDefault

Signature

export declare function preventDefault<R, E, Ev extends Event>(
  handler: (event: Ev) => Effect.Effect<unknown, E, R>,
  options?: AddEventListenerOptions
): EventHandler<Ev, E, R>

Added in v1.0.0

stopImmediatePropagation

Signature

export declare function stopImmediatePropagation<R, E, Ev extends Event>(
  handler: (event: Ev) => Effect.Effect<unknown, E, R>,
  options?: AddEventListenerOptions
): EventHandler<Ev, E, R>

Added in v1.0.0

stopPropagation

Signature

export declare function stopPropagation<R, E, Ev extends Event>(
  handler: (event: Ev) => Effect.Effect<unknown, E, R>,
  options?: AddEventListenerOptions
): EventHandler<Ev, E, R>

Added in v1.0.0

target

Signature

export declare function target<T extends HTMLElement>(eventOptions?: {
  preventDefault?: boolean
  stopPropagation?: boolean
  stopImmediatePropagation?: boolean
})

Added in v1.0.0