Conditional actions in Svelte

If you want to apply an action only under certain conditions, you can simply wrap the action into another action.

function conditionalAction(node, { action, params, condition }) {
	if (condition) {
		return action(node, params);
	}
}
<div use:conditionAlction={{ action: myAction, params: 1, condition: true }} />