1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-23 00:59:38 +01:00
deka-dom-el/src/events.js

11 lines
438 B
JavaScript
Raw Normal View History

import { isSignal } from './signals.js';
export function listen(event, listener, options){
if(isSignal(event)) return event.listeners.add(listener);
return element=> element.addEventListener(event, listener, options);
}
export function dispatch(event, detail){
if(typeof event === "string")
event= typeof detail==="undefined" ? new Event(event) : new CustomEvent(event, { detail });
return element=> element.dispatchEvent(event);
}