Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface AskListener<R, E, D, Mode>

Method signatures that set the event listener function and return event handlers.

AskRoot => AskEvent => AskSelector => AskListener builds EventHandler

Returns one or many EventHandler instances.

Type parameters

  • R: Element

  • E: Event

  • D: Element

  • Mode: BuildMode

Hierarchy

  • AskListener

Index

Methods

Methods

listen

  • listen(listener: DelegationListener<D, E, R>, listenerOptions?: boolean | AddEventListenerOptions): Build<Mode, R>
  • Takes the event listener function. Uses the previously constructed types for delegator elements and event instances to provide full type inference inside listener callbacks.

    returns one EventHandler instance when the build started with either global() or within(), or an array of EventHandler instances when the build started with withinMany().

    example
    // Returns either one handler
    const oneHandler: EventHandler<HTMLElement> = EventDelegation
        .global()
        .events('click')
        .select('button')
        .listen((e) => e.delegator.disabled = true)
    
    // or many handlers
    const manyHandlers: EventHandler<HTMLFormElement>[] = EventDelegation
        .withinMany('form')
        .events('click')
        .select('button')
        .listen((e) => e.delegator.disabled = true)
    

    Parameters

    • listener: DelegationListener<D, E, R>
    • Optional listenerOptions: boolean | AddEventListenerOptions

    Returns Build<Mode, R>