diff --git a/packages/effect-fc/src/Form.ts b/packages/effect-fc/src/Form.ts index e490bce..d473efb 100644 --- a/packages/effect-fc/src/Form.ts +++ b/packages/effect-fc/src/Form.ts @@ -1,5 +1,5 @@ import * as AsyncData from "@typed/async-data" -import { Array, Duration, Effect, Equal, Equivalence, identity, Option, ParseResult, pipe, Pipeable, Schema, Scope, Stream, Subscribable, SubscriptionRef } from "effect" +import { Array, Duration, Effect, Equal, Equivalence, identity, Option, ParseResult, pipe, Pipeable, Ref, Schema, Scope, Stream, Subscribable, SubscriptionRef } from "effect" import type { NoSuchElementException } from "effect/Cause" import * as React from "react" import { Hooks } from "./hooks/index.js" @@ -235,18 +235,18 @@ export const useInput: { Stream.runForEach( Stream.drop(field.encodedValueRef, 1), upstreamEncodedValue => Effect.whenEffect( - SubscriptionRef.set(internalValueRef, upstreamEncodedValue), + Ref.set(internalValueRef, upstreamEncodedValue), Effect.andThen(internalValueRef, internalValue => !Equal.equals(upstreamEncodedValue, internalValue)), ), ), Stream.runForEach( internalValueRef.changes.pipe( + Stream.drop(1), Stream.changesWith(Equivalence.strict()), options?.debounce ? Stream.debounce(options.debounce) : identity, - Stream.drop(1), ), - internalValue => SubscriptionRef.set(field.encodedValueRef, internalValue), + internalValue => Ref.set(field.encodedValueRef, internalValue), ), ], { concurrency: "unbounded" }), [field, internalValueRef]) diff --git a/packages/effect-fc/src/types/SubscriptionSubRef.ts b/packages/effect-fc/src/types/SubscriptionSubRef.ts index 1abeaac..c007397 100644 --- a/packages/effect-fc/src/types/SubscriptionSubRef.ts +++ b/packages/effect-fc/src/types/SubscriptionSubRef.ts @@ -78,7 +78,7 @@ extends Effectable.Class implements SubscriptionSubRef { return Effect.Do.pipe( Effect.bind("b", (): Effect.Effect> => this.parent), Effect.bind("ca", ({ b }) => f(this.getter(b))), - Effect.tap(({ b, ca: [, a] }) => Ref.set(this.parent, this.setter(b, a))), + Effect.tap(({ b, ca: [, a] }) => SubscriptionRef.set(this.parent, this.setter(b, a))), Effect.map(({ ca: [c] }) => c), ) }