0.2.2 #31
@@ -199,19 +199,13 @@ export const field = <A, I, R, SA, SE, SR, const P extends PropertyPath.Paths<No
|
|||||||
|
|
||||||
SubscriptionSubRef.makeFromPath(self.encodedValueRef, path),
|
SubscriptionSubRef.makeFromPath(self.encodedValueRef, path),
|
||||||
|
|
||||||
pipe(
|
SubscribableInternal.flatMapSubscriptionRef(self.errorRef, Option.match({
|
||||||
Option.match({
|
onSome: flow(
|
||||||
onSome: (v: ParseResult.ParseError) => Effect.andThen(
|
ParseResult.ArrayFormatter.formatError,
|
||||||
ParseResult.ArrayFormatter.formatError(v),
|
Effect.map(Array.filter(issue => PropertyPath.equivalence(issue.path, path))),
|
||||||
Array.filter(issue => PropertyPath.equivalence(issue.path, path)),
|
),
|
||||||
),
|
onNone: () => Effect.succeed([]),
|
||||||
onNone: () => Effect.succeed([]),
|
})),
|
||||||
}),
|
|
||||||
filter => SubscribableInternal.make({
|
|
||||||
get: Effect.flatMap(self.errorRef.get, filter),
|
|
||||||
get changes() { return Stream.flatMap(self.errorRef.changes, filter) },
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
pipe(
|
pipe(
|
||||||
Option.isSome,
|
Option.isSome,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { type Effect, Effectable, Readable, type Stream, Subscribable } from "effect"
|
import { Effect, Effectable, Readable, Stream, Subscribable, type SubscriptionRef } from "effect"
|
||||||
|
|
||||||
|
|
||||||
class SubscribableImpl<A, E, R>
|
class SubscribableImpl<A, E, R>
|
||||||
@@ -22,3 +22,11 @@ export const make = <A, E, R>(values: {
|
|||||||
readonly get: Effect.Effect<A, E, R>
|
readonly get: Effect.Effect<A, E, R>
|
||||||
readonly changes: Stream.Stream<A, E, R>
|
readonly changes: Stream.Stream<A, E, R>
|
||||||
}): Subscribable.Subscribable<A, E, R> => new SubscribableImpl(values.get, values.changes)
|
}): Subscribable.Subscribable<A, E, R> => new SubscribableImpl(values.get, values.changes)
|
||||||
|
|
||||||
|
export const flatMapSubscriptionRef = <A, B, E, R>(
|
||||||
|
ref: SubscriptionRef.SubscriptionRef<A>,
|
||||||
|
flatMap: (value: NoInfer<A>) => Effect.Effect<B, E, R>,
|
||||||
|
): Subscribable.Subscribable<B, E, R> => make({
|
||||||
|
get: Effect.flatMap(ref, flatMap),
|
||||||
|
get changes() { return Stream.flatMap(ref.changes, flatMap) },
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user