,
+export const useInput = Effect.fnUntraced(function* (
+ form: Form
,
options?: useInput.Options,
-): Effect.fn.Return, Cause.NoSuchElementException, Scope.Scope> {
+): Effect.fn.Return, ER, Scope.Scope> {
const internalValueLens = yield* Component.useOnChange(() => Effect.gen(function*() {
- const internalValueLens = yield* Lens.get(field.encodedValue).pipe(
+ const internalValueLens = yield* Lens.get(form.encodedValue).pipe(
Effect.flatMap(SubscriptionRef.make),
Effect.map(Lens.fromSubscriptionRef),
)
yield* Effect.forkScoped(Effect.all([
Stream.runForEach(
- Stream.drop(field.encodedValue.changes, 1),
+ Stream.drop(form.encodedValue.changes, 1),
upstreamEncodedValue => Effect.whenEffect(
Lens.set(internalValueLens, upstreamEncodedValue),
Effect.andThen(Lens.get(internalValueLens), internalValue => !Equal.equals(upstreamEncodedValue, internalValue)),
@@ -281,12 +281,12 @@ export const useInput = Effect.fnUntraced(function* (
Stream.changesWith(Equal.equivalence()),
options?.debounce ? Stream.debounce(options.debounce) : identity,
),
- internalValue => Lens.set(field.encodedValue, internalValue),
+ internalValue => Lens.set(form.encodedValue, internalValue),
),
], { concurrency: "unbounded" }))
return internalValueLens
- }), [field, options?.debounce])
+ }), [form, options?.debounce])
const [value, setValue] = yield* Lens.useState(internalValueLens)
return { value, setValue }
@@ -303,10 +303,10 @@ export namespace useOptionalInput {
}
}
-export const useOptionalInput = Effect.fnUntraced(function* (
- field: FormField>,
+export const useOptionalInput = Effect.fnUntraced(function* (
+ field: Form
, ER, EW>,
options: useOptionalInput.Options,
-): Effect.fn.Return, Cause.NoSuchElementException, Scope.Scope> {
+): Effect.fn.Return, ER, Scope.Scope> {
const [enabledLens, internalValueLens] = yield* Component.useOnChange(() => Effect.gen(function*() {
const [enabledLens, internalValueLens] = yield* Effect.flatMap(
Lens.get(field.encodedValue),