Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OnBuilder

The on builder provides services to listen to DOM events. Listeners are added on connectedCallback and removed on disconnectedCallback.

Hierarchy

  • OnBuilder

Implements

Index

Constructors

constructor

  • new OnBuilder(clauses: string, callback?: OnListener, forceCapture?: boolean, forcePreventDefault?: boolean, forceStopPropagation?: boolean, selector?: string, isShadow?: boolean): OnBuilder
  • Parameters

    • clauses: string
    • Default value callback: OnListener = noop
    • Default value forceCapture: boolean = false
    • Default value forcePreventDefault: boolean = false
    • Default value forceStopPropagation: boolean = false
    • Default value selector: string = undefined
    • Default value isShadow: boolean = false

    Returns OnBuilder

Properties

Private callback

callback: OnListener

Private clauses

clauses: string

Private forceCapture

forceCapture: boolean

Private forcePreventDefault

forcePreventDefault: boolean

Private forceStopPropagation

forceStopPropagation: boolean

Private isShadow

isShadow: boolean

Private selector

selector: string

Methods

build

capture

  • capture(): this
  • Force the listener execution on the capture phase.

    Returns this

delegate

  • delegate(selector: string): this
  • Event delegation allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future. c.f. JQuery doc

    Parameters

    • selector: string

      the selector

    Returns this

invoke

  • Register the listener.

    Parameters

    Returns this

prevent

  • prevent(): this
  • Force the usage of preventDefault() once the event is received.

    Returns this

shadow

  • shadow(): this
  • By default, the builder listen to events from the CustomElement DOM. With this option, the builder will listen to from the attached (and opened) shadow DOM.

    Returns this

skip

  • skip(): this
  • Apply .prevent() and .stop().

    Returns this

stop

  • stop(): this
  • Force the usage of stopPropagation() once the event is received.

    Returns this

Static get

  • Provide a fresh builder.

    Parameters

    • clauses: string

      the clauses

    Returns OnBuilder

Static listen

  • Method Decorator used to register a listener listening to event changes.

    Parameters

    Returns (Anonymous function)

Generated using TypeDoc