Refactor
All checks were successful
Lint / lint (push) Successful in 43s

This commit is contained in:
Julien Valverdé
2026-05-02 02:26:01 +02:00
parent 042f3a8587
commit fb650c0c0d

View File

@@ -1,4 +1,4 @@
import { Array, type Context, Effect, Equal, Fiber, Option, ParseResult, Pipeable, Predicate, Schema, type Scope, Stream, SubscriptionRef } from "effect"
import { Array, type Context, Effect, Equal, Fiber, flow, 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"
@@ -115,7 +115,7 @@ export class SynchronizedFormImpl<
)
}
synchronizeEncodedValue(encodedValue: I): Effect.Effect<void, never, never> {
synchronizeEncodedValue(encodedValue: I): Effect.Effect<void, TER | TEW, never> {
return Lens.get(this.validationFiber).pipe(
Effect.andThen(Option.match({
onSome: Fiber.interrupt,
@@ -128,21 +128,23 @@ export class SynchronizedFormImpl<
)
)),
Effect.tap(fiber => Lens.set(this.validationFiber, Option.some(fiber))),
Effect.andThen(Fiber.join),
Effect.flatMap(Fiber.join),
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.flatMap(value => Effect.ensuring(
Lens.set(this.isCommitting, true).pipe(
Effect.andThen(Lens.set(this.issues, Array.empty())),
Effect.andThen(Lens.set(this.target, value)),
),
Lens.set(this.isCommitting, false),
)),
Effect.catchIf(
ParseResult.isParseError,
flow(
ParseResult.ArrayFormatter.formatError,
Effect.flatMap(v => Lens.set(this.issues, v)),
),
),
Effect.ignore,
Effect.provide(this.context),
)
}