@@ -1,5 +1,5 @@
|
|||||||
import * as AsyncData from "@typed/async-data"
|
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 type { NoSuchElementException } from "effect/Cause"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Hooks } from "./hooks/index.js"
|
import { Hooks } from "./hooks/index.js"
|
||||||
@@ -235,18 +235,18 @@ export const useInput: {
|
|||||||
Stream.runForEach(
|
Stream.runForEach(
|
||||||
Stream.drop(field.encodedValueRef, 1),
|
Stream.drop(field.encodedValueRef, 1),
|
||||||
upstreamEncodedValue => Effect.whenEffect(
|
upstreamEncodedValue => Effect.whenEffect(
|
||||||
SubscriptionRef.set(internalValueRef, upstreamEncodedValue),
|
Ref.set(internalValueRef, upstreamEncodedValue),
|
||||||
Effect.andThen(internalValueRef, internalValue => !Equal.equals(upstreamEncodedValue, internalValue)),
|
Effect.andThen(internalValueRef, internalValue => !Equal.equals(upstreamEncodedValue, internalValue)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Stream.runForEach(
|
Stream.runForEach(
|
||||||
internalValueRef.changes.pipe(
|
internalValueRef.changes.pipe(
|
||||||
|
Stream.drop(1),
|
||||||
Stream.changesWith(Equivalence.strict()),
|
Stream.changesWith(Equivalence.strict()),
|
||||||
options?.debounce ? Stream.debounce(options.debounce) : identity,
|
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])
|
], { concurrency: "unbounded" }), [field, internalValueRef])
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ extends Effectable.Class<A> implements SubscriptionSubRef<A, B> {
|
|||||||
return Effect.Do.pipe(
|
return Effect.Do.pipe(
|
||||||
Effect.bind("b", (): Effect.Effect<Effect.Effect.Success<B>> => this.parent),
|
Effect.bind("b", (): Effect.Effect<Effect.Effect.Success<B>> => this.parent),
|
||||||
Effect.bind("ca", ({ b }) => f(this.getter(b))),
|
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),
|
Effect.map(({ ca: [c] }) => c),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user