@jay-js/ui
Version:
A library of UI components for Jay JS with Tailwind CSS and daisyUI.
12 lines (11 loc) • 397 B
JavaScript
/**
* A hook to handle event listeners
*
* @param type - The event type to listen for (e.g., 'click', 'input')
* @param listeners - An object containing event handler functions
* @returns void
*/ export function useListener(type, listeners) {
const listener = Object.entries(listeners).find(([key, _value])=>key === type);
if (!listener || !listener[1]) return;
listener[1]();
}