0.2.6 #49
@@ -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 Form from "./Form.js"
|
||||||
import * as Lens from "./Lens.js"
|
import * as Lens from "./Lens.js"
|
||||||
import * as Subscribable from "./Subscribable.js"
|
import * as Subscribable from "./Subscribable.js"
|
||||||
@@ -121,35 +121,25 @@ export class SynchronizedFormImpl<
|
|||||||
onSome: Fiber.interrupt,
|
onSome: Fiber.interrupt,
|
||||||
onNone: () => Effect.void,
|
onNone: () => Effect.void,
|
||||||
})),
|
})),
|
||||||
Effect.andThen(
|
Effect.andThen(Effect.forkScoped(
|
||||||
Effect.forkScoped(Effect.onExit(
|
Effect.ensuring(
|
||||||
Schema.decode(this.schema, { errors: "all" })(encodedValue),
|
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()),
|
Lens.set(this.validationFiber, Option.none()),
|
||||||
),
|
)
|
||||||
))
|
)),
|
||||||
),
|
|
||||||
Effect.tap(fiber => Lens.set(this.validationFiber, Option.some(fiber))),
|
Effect.tap(fiber => Lens.set(this.validationFiber, Option.some(fiber))),
|
||||||
Effect.andThen(Fiber.join),
|
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(
|
Effect.andThen(
|
||||||
Lens.set(this.isCommitting, true),
|
Lens.set(this.isCommitting, true),
|
||||||
Lens.set(this.target, value),
|
Lens.set(this.target, value),
|
||||||
),
|
),
|
||||||
() => Lens.set(this.isCommitting, false),
|
Lens.set(this.isCommitting, false),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
Effect.ignore,
|
Effect.ignore,
|
||||||
|
|||||||
Reference in New Issue
Block a user