0.1.3 #4

Merged
Thilawyn merged 90 commits from next into master 2025-08-23 03:07:28 +02:00
Showing only changes of commit 41b1396a58 - Show all commits

View File

@@ -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<ParseResult.ParseError>())
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)),