From 283c3884d8fa52328154e3cee306112bd924f114 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lopes" <26071571+TGlide@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:20:02 +0100 Subject: [PATCH] fix docs --- .../runed/src/lib/functions/useEventListener/index.ts | 2 +- ...useEventListener.ts => useEventListener.svelte.ts} | 6 +++--- sites/docs/content/functions/use-event-listener.md | 11 +++++------ .../lib/components/demos/use-event-listener.svelte | 9 +++++---- 4 files changed, 14 insertions(+), 14 deletions(-) rename packages/runed/src/lib/functions/useEventListener/{useEventListener.ts => useEventListener.svelte.ts} (90%) diff --git a/packages/runed/src/lib/functions/useEventListener/index.ts b/packages/runed/src/lib/functions/useEventListener/index.ts index a0b178c1..4455e9d1 100644 --- a/packages/runed/src/lib/functions/useEventListener/index.ts +++ b/packages/runed/src/lib/functions/useEventListener/index.ts @@ -1 +1 @@ -export * from "./useEventListener.js"; +export * from "./useEventListener.svelte.js"; diff --git a/packages/runed/src/lib/functions/useEventListener/useEventListener.ts b/packages/runed/src/lib/functions/useEventListener/useEventListener.svelte.ts similarity index 90% rename from packages/runed/src/lib/functions/useEventListener/useEventListener.ts rename to packages/runed/src/lib/functions/useEventListener/useEventListener.svelte.ts index e5650849..36150e53 100644 --- a/packages/runed/src/lib/functions/useEventListener/useEventListener.ts +++ b/packages/runed/src/lib/functions/useEventListener/useEventListener.svelte.ts @@ -34,12 +34,12 @@ export function useEventListener( ): void; export function useEventListener( - target: ValueOrGetter, + _target: ValueOrGetter, 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)); } diff --git a/sites/docs/content/functions/use-event-listener.md b/sites/docs/content/functions/use-event-listener.md index e07196db..aea64e15 100644 --- a/sites/docs/content/functions/use-event-listener.md +++ b/sites/docs/content/functions/use-event-listener.md @@ -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); -
-

You've clicked {count} {count === 1 ? "Time" : "Times"}

-
+

You've clicked {count} {count === 1 ? "Time" : "Times"}

``` diff --git a/sites/docs/src/lib/components/demos/use-event-listener.svelte b/sites/docs/src/lib/components/demos/use-event-listener.svelte index 94304e0d..9bc5543c 100644 --- a/sites/docs/src/lib/components/demos/use-event-listener.svelte +++ b/sites/docs/src/lib/components/demos/use-event-listener.svelte @@ -2,12 +2,13 @@ import { useEventListener } from "runed"; let count = $state(0); + function increment() { + count++; + } - $effect(() => { - useEventListener(document, "click", () => count++); - }); + useEventListener(() => document, "click", increment); -
+

You've clicked {count} {count === 1 ? "Time" : "Times"}