@@ -24,7 +24,7 @@ export interface SynchronizedForm<
|
||||
readonly target: Lens.Lens<A, TER, TEW, TRR, TRW>
|
||||
readonly validationFiber: Subscribable.Subscribable<Option.Option<Fiber.Fiber<A, ParseResult.ParseError>>, never, never>
|
||||
|
||||
readonly run: Effect.Effect<void, ParseResult.ParseError | TER>
|
||||
readonly run: Effect.Effect<void, TER>
|
||||
}
|
||||
|
||||
export class SynchronizedFormImpl<
|
||||
@@ -60,7 +60,7 @@ export class SynchronizedFormImpl<
|
||||
super()
|
||||
}
|
||||
|
||||
get run(): Effect.Effect<void, ParseResult.ParseError | TER> {
|
||||
get run(): Effect.Effect<void, TER> {
|
||||
return this.runSemaphore.withPermits(1)(Effect.provide(
|
||||
Effect.all([
|
||||
Stream.runForEach(
|
||||
@@ -101,25 +101,25 @@ export class SynchronizedFormImpl<
|
||||
),
|
||||
() => Lens.set(this.isCommitting, false),
|
||||
)),
|
||||
Effect.forkScoped,
|
||||
Effect.ignore,
|
||||
),
|
||||
),
|
||||
|
||||
Stream.runForEach(
|
||||
Stream.drop(this.target.changes, 1),
|
||||
|
||||
targetValue => Effect.flatMap(
|
||||
Schema.encode(this.schema, { errors: "all" })(targetValue),
|
||||
encodedValue => Effect.whenEffect(
|
||||
targetValue => Schema.encode(this.schema, { errors: "all" })(targetValue).pipe(
|
||||
Effect.flatMap(encodedValue => Effect.whenEffect(
|
||||
Lens.set(this.encodedValue, encodedValue),
|
||||
Effect.map(
|
||||
Lens.get(this.encodedValue),
|
||||
currentEncodedValue => !Equal.equals(encodedValue, currentEncodedValue),
|
||||
),
|
||||
)),
|
||||
Effect.ignore,
|
||||
),
|
||||
),
|
||||
),
|
||||
], { concurrency: "unbounded", discard: true }),
|
||||
], { concurrency: "unbounded" }),
|
||||
|
||||
this.context,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user