0.2.1 #26

Merged
Thilawyn merged 144 commits from next into master 2025-12-01 23:37:40 +01:00
2 changed files with 26 additions and 14 deletions
Showing only changes of commit cd937a86c7 - Show all commits

View File

@@ -160,8 +160,8 @@ export const submit = <A, I, R, SA, SE, SR, SP>(
> => Effect.whenEffect( > => Effect.whenEffect(
self.valueRef.pipe( self.valueRef.pipe(
Effect.andThen(identity), Effect.andThen(identity),
Effect.andThen(value => Result.forkEffect( Effect.andThen(value => Result.unsafeForkEffect(
self.onSubmit(value) as Effect.Effect<SA, SE, Result.forkEffect.InputContext<SR, SP>>, self.onSubmit(value),
{ initialProgress: self.initialSubmitProgress }, { initialProgress: self.initialSubmitProgress },
)), )),
Effect.andThen(([sub]) => Effect.all([Effect.succeed(sub), sub.get])), Effect.andThen(([sub]) => Effect.all([Effect.succeed(sub), sub.get])),

View File

@@ -186,22 +186,21 @@ export const makeProgressLayer = <A, E, P = never>(): Layer.Layer<
})) }))
export namespace forkEffect { export namespace unsafeForkEffect {
export type InputContext<R, P> = R extends Progress<infer X> ? [X] extends [P] ? R : never : R export type OutputContext<A, E, R, P> = Scope.Scope | Exclude<R, State<A, E, P> | Progress<P>>
export type OutputContext<R> = Scope.Scope | Exclude<R, Progress<any> | Progress<never>>
export interface Options<P> { export interface Options<P> {
readonly initialProgress?: P readonly initialProgress?: P
} }
} }
export const forkEffect = <A, E, R, P = never>( export const unsafeForkEffect = <A, E, R, P = never>(
effect: Effect.Effect<A, E, forkEffect.InputContext<R, NoInfer<P>>>, effect: Effect.Effect<A, E, R>,
options?: forkEffect.Options<P>, options?: unsafeForkEffect.Options<P>,
): Effect.Effect< ): Effect.Effect<
readonly [result: Subscribable.Subscribable<Result<A, E, P>, never, never>, fiber: Fiber.Fiber<A, E>], readonly [result: Subscribable.Subscribable<Result<A, E, P>, never, never>, fiber: Fiber.Fiber<A, E>],
never, never,
Scope.Scope | forkEffect.OutputContext<R> Scope.Scope | unsafeForkEffect.OutputContext<A, E, R, P>
> => Effect.Do.pipe( > => Effect.Do.pipe(
Effect.bind("ref", () => Ref.make<Result<A, E, P>>(initial())), Effect.bind("ref", () => Ref.make<Result<A, E, P>>(initial())),
Effect.bind("pubsub", () => PubSub.unbounded<Result<A, E, P>>()), Effect.bind("pubsub", () => PubSub.unbounded<Result<A, E, P>>()),
@@ -231,8 +230,21 @@ export const forkEffect = <A, E, R, P = never>(
}), }),
fiber, fiber,
]), ]),
) as Effect.Effect< )
readonly [result: Subscribable.Subscribable<Result<A, E, P>, never, never>, fiber: Fiber.Fiber<A, E>],
never, export namespace forkEffect {
Scope.Scope | forkEffect.OutputContext<R> export type InputContext<R, P> = R extends Progress<infer X> ? [X] extends [P] ? R : never : R
> export type OutputContext<A, E, R, P> = unsafeForkEffect.OutputContext<A, E, R, P>
export interface Options<P> extends unsafeForkEffect.Options<P> {}
}
export const forkEffect: {
<A, E, R, P = never>(
effect: Effect.Effect<A, E, forkEffect.InputContext<R, NoInfer<P>>>,
options?: forkEffect.Options<P>,
): Effect.Effect<
readonly [result: Subscribable.Subscribable<Result<A, E, P>, never, never>, fiber: Fiber.Fiber<A, E>],
never,
Scope.Scope | forkEffect.OutputContext<A, E, R, P>
>
} = unsafeForkEffect