- listener(event, options?): ((listener) => ((elements) => void))
Parameters
- event: keyof HTMLElementEventMap
Optional
options: AddEventListenerOptions
Returns ((listener) => ((elements) => void))
- (listener): ((elements) => void)
Returns ((elements) => void)
- (elements): void
Parameters
- elements: Element | Iterable<Element>
Returns void
Creates a function to be called with listener functions to return `apply
@example import { listener } from 'deleight/dom/components' import { apply } from 'deleight/dom/apply'
document.body.innerHTML = `
I am a paragraph
const componentFactory = listener('click', { once: true })
const btns = []; const component = componentFactory(e => btns.push(e.target.textContent));
const subComponents = { button: component } apply({ section: subComponents, article: subComponents });