Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TGlide committed Apr 22, 2024
1 parent af2bbdf commit 283c388
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/runed/src/lib/functions/useEventListener/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./useEventListener.js";
export * from "./useEventListener.svelte.js";
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export function useEventListener(
): void;

export function useEventListener(
target: ValueOrGetter<EventTarget>,
_target: ValueOrGetter<EventTarget>,
event: string,
handler: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions
) {
const $target = boxed(target);
const target = boxed(_target);

$effect(() => addEventListener($target.value, event, handler, options));
$effect(() => addEventListener(target.value, event, handler, options));
}
11 changes: 5 additions & 6 deletions sites/docs/content/functions/use-event-listener.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import { UseEventListenerDemo } from '$lib/components/demos';
import { useEventListener } from "runed";
let count = $state(0);
function increment() {
count++;
}
$effect(() => {
useEventListener(document, "click", () => count++);
});
useEventListener(() => document, "click", increment);
</script>
<div class="rounded-md bg-card p-8">
<p>You've clicked {count} {count === 1 ? "Time" : "Times"}</p>
</div>
<p>You've clicked {count} {count === 1 ? "Time" : "Times"}</p>
```
9 changes: 5 additions & 4 deletions sites/docs/src/lib/components/demos/use-event-listener.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import { useEventListener } from "runed";
let count = $state(0);
function increment() {
count++;
}
$effect(() => {
useEventListener(document, "click", () => count++);
});
useEventListener(() => document, "click", increment);
</script>

<div class="rounded-md bg-card p-8">
<div class="select-none rounded-md bg-card p-8">
<p>You've clicked {count} {count === 1 ? "Time" : "Times"}</p>
</div>

0 comments on commit 283c388

Please sign in to comment.