0.2.6 #49
@@ -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 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"
|
||||||
@@ -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(
|
return Lens.get(this.validationFiber).pipe(
|
||||||
Effect.andThen(Option.match({
|
Effect.andThen(Option.match({
|
||||||
onSome: Fiber.interrupt,
|
onSome: Fiber.interrupt,
|
||||||
@@ -128,21 +128,23 @@ export class SynchronizedFormImpl<
|
|||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
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.flatMap(Fiber.join),
|
||||||
|
|
||||||
Effect.catchTag("ParseError", e => ParseResult.ArrayFormatter.formatError(e).pipe(
|
Effect.flatMap(value => Effect.ensuring(
|
||||||
Effect.flatMap(v => Lens.set(this.issues, v)),
|
|
||||||
Effect.andThen(Effect.fail(e)),
|
|
||||||
)),
|
|
||||||
Effect.tap(value => Effect.ensuring(
|
|
||||||
Lens.set(this.isCommitting, true).pipe(
|
Lens.set(this.isCommitting, true).pipe(
|
||||||
Effect.andThen(Lens.set(this.issues, Array.empty())),
|
Effect.andThen(Lens.set(this.issues, Array.empty())),
|
||||||
Effect.andThen(Lens.set(this.target, value)),
|
Effect.andThen(Lens.set(this.target, value)),
|
||||||
),
|
),
|
||||||
Lens.set(this.isCommitting, false),
|
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),
|
Effect.provide(this.context),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user