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