UNPKG

svelte-ux

Version:

- Increment version in `package.json` and commit as `Version bump to x.y.z` - `npm run publish`

22 lines (21 loc) 730 B
/** * Helper action to handle multiple actions as a single action. Useful for adding actions for custom components */ export default function multi(node, actions) { let destroyFuncs = undefined; function update() { destroy(); if (actions) { destroyFuncs = actions(node) .filter((x) => x) .map((x) => (x ? x.destroy : () => { })); } } function destroy() { destroyFuncs === null || destroyFuncs === void 0 ? void 0 : destroyFuncs.forEach((fn) => fn === null || fn === void 0 ? void 0 : fn()); } if (actions === null || actions === void 0 ? void 0 : actions.length) { update(); return { update, destroy }; } }