@@ -11,6 +11,7 @@ export type TypeId = typeof TypeId
|
||||
export interface Form<in out A, in out I = A, out R = never>
|
||||
extends Pipeable.Pipeable {
|
||||
readonly schema: Schema.Schema<A, I, R>,
|
||||
/** A reference to the latest valid value produced by the form, if any. */
|
||||
readonly valueRef: SubscriptionRef.SubscriptionRef<Option.Option<A>>,
|
||||
readonly encodedValueRef: SubscriptionRef.SubscriptionRef<I>,
|
||||
readonly errorRef: SubscriptionRef.SubscriptionRef<Option.Option<ParseResult.ParseError>>,
|
||||
@@ -73,7 +74,7 @@ export const make: {
|
||||
const run = <A, I, R>(self: Form<A, I, R>) => Stream.runForEach(
|
||||
self.encodedValueRef.changes,
|
||||
flow(
|
||||
Schema.decode(self.schema),
|
||||
Schema.decode(self.schema, { errors: "all" }),
|
||||
Effect.andThen(v => SubscriptionRef.set(self.valueRef, Option.some(v))),
|
||||
Effect.andThen(SubscriptionRef.set(self.errorRef, Option.none())),
|
||||
Effect.catchTag("ParseError", e => SubscriptionRef.set(self.errorRef, Option.some(e)))
|
||||
|
||||
Reference in New Issue
Block a user