UNPKG

svelte-event

Version:

svelte-event provides a set of wrapper functions for adding modifiers to event handlers and a versatile `event` action for comprehensive event listener management in Svelte.

17 lines (16 loc) 399 B
/** Composes multiple event handlers into a single handler * @example * ```ts * const handler = compose( * (event) => console.log('first handler', event), * (event) => console.log('second handler', event), * ); * ``` */ export function compose(...handlers) { return function (event) { for (const handler of handlers) { handler.call(this, event); } }; }