UseEventListener

A function that attaches an automatically disposed event listener.

Demo

You've clicked 0 Times

Usage

	<script lang="ts">
	import { useEventListener } from "runed";
 
	let count = $state(0);
	function increment() {
		count++;
	}
 
	useEventListener(() => document, "click", increment);
</script>
 
<p>You've clicked {count} {count === 1 ? "Time" : "Times"}</p>	
MIT

© 2024 Svecosystem Team