This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Array, Cause, Chunk, type Context, Effect, Exit, Fiber, Option, ParseResult, Pipeable, Predicate, Schema, type Scope, Stream, SubscriptionRef } from "effect"
|
||||
import { Array, type Context, Effect, Fiber, Option, ParseResult, Pipeable, Predicate, Schema, type Scope, Stream, SubscriptionRef } from "effect"
|
||||
import * as Form from "./Form.js"
|
||||
import * as Lens from "./Lens.js"
|
||||
import * as Subscribable from "./Subscribable.js"
|
||||
@@ -121,35 +121,25 @@ export class SynchronizedFormImpl<
|
||||
onSome: Fiber.interrupt,
|
||||
onNone: () => Effect.void,
|
||||
})),
|
||||
Effect.andThen(
|
||||
Effect.forkScoped(Effect.onExit(
|
||||
Effect.andThen(Effect.forkScoped(
|
||||
Effect.ensuring(
|
||||
Schema.decode(this.schema, { errors: "all" })(encodedValue),
|
||||
exit => Effect.andThen(
|
||||
Exit.matchEffect(exit, {
|
||||
onSuccess: () => Lens.set(this.issues, Array.empty()),
|
||||
onFailure: c => Option.match(
|
||||
Chunk.findFirst(Cause.failures(c), e => e._tag === "ParseError"),
|
||||
{
|
||||
onSome: e => Effect.flatMap(
|
||||
ParseResult.ArrayFormatter.formatError(e),
|
||||
v => Lens.set(this.issues, v),
|
||||
),
|
||||
onNone: () => Effect.void,
|
||||
},
|
||||
),
|
||||
}),
|
||||
Lens.set(this.validationFiber, Option.none()),
|
||||
),
|
||||
))
|
||||
),
|
||||
)
|
||||
)),
|
||||
Effect.tap(fiber => Lens.set(this.validationFiber, Option.some(fiber))),
|
||||
Effect.andThen(Fiber.join),
|
||||
Effect.tap(value => Effect.onExit(
|
||||
|
||||
Effect.catchTag("ParseError", e => ParseResult.ArrayFormatter.formatError(e).pipe(
|
||||
Effect.flatMap(v => Lens.set(this.issues, v)),
|
||||
Effect.andThen(Effect.fail(e)),
|
||||
)),
|
||||
Effect.tap(value => Effect.ensuring(
|
||||
Effect.andThen(
|
||||
Lens.set(this.isCommitting, true),
|
||||
Lens.set(this.target, value),
|
||||
),
|
||||
() => Lens.set(this.isCommitting, false),
|
||||
Lens.set(this.isCommitting, false),
|
||||
)),
|
||||
|
||||
Effect.ignore,
|
||||
|
||||
Reference in New Issue
Block a user