🀄️ Osagai

  • Docs
Docs Menu
  • Getting Started
  • API reference
    • osagai
    • dom
    • events
    • lifecycles

events

Overview

The osagai/events module has functions for adding event listeners in your custom element DOM tree. Use this module if you need to listen to events.

  • on

Reference

on

on(eventType, element, callback) => Promise

Add an event listener to the element and return a promise when this is done.

Parameters
eventType

A case-sensitive string representing the event typeto listen for

element

Instance of the element to add the event listener. It could be also a promise that resolve with the element (ex. query and queryAll functions from the component function)

callback

A function that runs when the event type occurs. It could also be an object that implements the EventListener interface.

Example
on('click', query('button'), (event) => {
  api.makeSomeMagic()
})

Contribute on Github! Edit this section.