From 41b1396a586c32066771e63984767c822b842aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Tue, 29 Jul 2025 03:32:17 +0200 Subject: [PATCH] Fix --- packages/effect-fc/src/hooks/Hooks/useInput.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/effect-fc/src/hooks/Hooks/useInput.ts b/packages/effect-fc/src/hooks/Hooks/useInput.ts index 4d32d7b..7d6a0ff 100644 --- a/packages/effect-fc/src/hooks/Hooks/useInput.ts +++ b/packages/effect-fc/src/hooks/Hooks/useInput.ts @@ -1,4 +1,4 @@ -import { type Duration, Effect, flow, Option, ParseResult, Ref, Schema, Stream, SubscriptionRef, Types } from "effect" +import { type Duration, Effect, flow, identity, Option, type ParseResult, Ref, Schema, Stream, SubscriptionRef, type Types } from "effect" import * as React from "react" import { useCallbackSync } from "./useCallbackSync.js" import { useFork } from "./useFork.js" @@ -30,7 +30,7 @@ export const useInput: { const [error, setError] = React.useState(Option.none()) yield* useFork(() => Effect.all([ - Stream.runForEach(options.ref, upstreamValue => + Stream.runForEach(options.ref.changes, upstreamValue => Effect.andThen(internalRef, internalValue => upstreamValue !== internalValue ? Effect.andThen(Schema.encode(options.schema)(upstreamValue), v => Ref.set(internalRef, v)) @@ -39,7 +39,7 @@ export const useInput: { ), Stream.runForEach( - options.debounce ? Stream.debounce(internalRef, options.debounce) : internalRef, + internalRef.changes.pipe(options.debounce ? Stream.debounce(options.debounce) : identity), flow( Schema.decode(options.schema), Effect.andThen(v => Ref.set(options.ref, v)),