diff --git a/packages/effect-fc/src/Result.ts b/packages/effect-fc/src/Result.ts index 4ddda52..f065082 100644 --- a/packages/effect-fc/src/Result.ts +++ b/packages/effect-fc/src/Result.ts @@ -29,7 +29,7 @@ export interface Initial extends Result.Prototype { export interface Running

extends Result.Prototype { readonly _tag: "Running" - readonly progress: Option.Option

+ readonly progress: P } export interface Success extends Result.Prototype { @@ -45,7 +45,7 @@ export interface Failure extends Result.Prototype { export interface Refreshing

{ readonly refreshing: true - readonly progress: Option.Option

+ readonly progress: P } @@ -96,7 +96,7 @@ const ResultPrototype = Object.freeze({ export interface ProgressService

{ - readonly update: (f: (previous: Option.Option

) => Option.Option

) => Effect.Effect + readonly update: (progress: P) => Effect.Effect } @@ -108,10 +108,7 @@ export const isFailure = (u: unknown): u is Failure => isResul export const isRefreshing = (u: unknown): u is Refreshing => isResult(u) && Predicate.hasProperty(u, "refreshing") && u.refreshing export const initial = (): Initial => Object.setPrototypeOf({ _tag: "Initial" }, ResultPrototype) -export const running =

(progress?: P): Running

=> Object.setPrototypeOf({ - _tag: "Running", - progress: Option.fromNullable(progress), -}, ResultPrototype) +export const running =

(progress?: P): Running

=> Object.setPrototypeOf({ _tag: "Running", progress }, ResultPrototype) export const succeed = (value: A): Success => Object.setPrototypeOf({ _tag: "Success", value }, ResultPrototype) export const fail = ( cause: Cause.Cause, @@ -125,7 +122,7 @@ export const refreshing = | Failure, P = never result: R, progress?: P, ): Omit>> & Refreshing

=> Object.setPrototypeOf( - Object.assign({}, result, { progress: Option.fromNullable(progress) }), + Object.assign({}, result, { progress }), Object.getPrototypeOf(result), ) @@ -149,9 +146,9 @@ export const toExit = ( } } -export const forkEffectScoped = ( - effect: Effect.Effect | R> -): Effect.Effect>, never, Scope.Scope | R> => Queue.unbounded>().pipe( +export const forkEffectScoped = ( + effect: Effect.Effect +): Effect.Effect>, never, Scope.Scope | R> => Queue.unbounded>().pipe( Effect.tap(Queue.offer(initial())), Effect.tap(queue => Effect.forkScoped(Effect.addFinalizer(() => Queue.shutdown(queue)).pipe( Effect.andThen(Queue.offer(queue, running())),