@@ -76,8 +76,9 @@ export class SynchronizedFormImpl<
|
|||||||
Schema.decode(this.schema, { errors: "all" })(encodedValue),
|
Schema.decode(this.schema, { errors: "all" })(encodedValue),
|
||||||
exit => Effect.andThen(
|
exit => Effect.andThen(
|
||||||
Exit.matchEffect(exit, {
|
Exit.matchEffect(exit, {
|
||||||
onSuccess: v => Lens.set(this.value, Option.some(v)).pipe(
|
onSuccess: v => Effect.andThen(
|
||||||
Effect.andThen(Lens.set(this.issues, Array.empty())),
|
Lens.set(this.value, Option.some(v)),
|
||||||
|
Lens.set(this.issues, Array.empty()),
|
||||||
),
|
),
|
||||||
onFailure: c => Option.match(Chunk.findFirst(Cause.failures(c), e => e._tag === "ParseError"), {
|
onFailure: c => Option.match(Chunk.findFirst(Cause.failures(c), e => e._tag === "ParseError"), {
|
||||||
onSome: e => Effect.flatMap(
|
onSome: e => Effect.flatMap(
|
||||||
@@ -108,14 +109,15 @@ export class SynchronizedFormImpl<
|
|||||||
Stream.runForEach(
|
Stream.runForEach(
|
||||||
Stream.drop(this.target.changes, 1),
|
Stream.drop(this.target.changes, 1),
|
||||||
|
|
||||||
targetValue => Schema.encode(this.schema, { errors: "all" })(targetValue).pipe(
|
targetValue => Effect.flatMap(
|
||||||
Effect.flatMap(encodedValue => Effect.whenEffect(
|
Schema.encode(this.schema, { errors: "all" })(targetValue),
|
||||||
|
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),
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
], { concurrency: "unbounded", discard: true }),
|
], { concurrency: "unbounded", discard: true }),
|
||||||
|
|||||||
Reference in New Issue
Block a user