0.2.1 #26
@@ -33,19 +33,17 @@ extends Pipeable.Class() implements Query<K, A, E, R, P> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readonly interrupt: Effect.Effect<void, never, never> = Effect.gen(this, function*() {
|
readonly interrupt: Effect.Effect<void, never, never> = Effect.gen(this, function*() {
|
||||||
return yield* Effect.andThen(this.fiber, Option.match({
|
return Option.match(yield* this.fiber, {
|
||||||
onSome: fiber => Effect.andThen(
|
onSome: Fiber.interrupt,
|
||||||
Fiber.interrupt(fiber),
|
|
||||||
SubscriptionRef.set(this.fiber, Option.none()),
|
|
||||||
),
|
|
||||||
onNone: () => Effect.void,
|
onNone: () => Effect.void,
|
||||||
}))
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
query(key: K): Effect.Effect<Result.Result<A, E, P>, never, Scope.Scope | R> {
|
query(key: K): Effect.Effect<Result.Result<A, E, P>, never, Scope.Scope | R> {
|
||||||
return this.fiber.pipe(
|
return Result.unsafeForkEffect(
|
||||||
Effect.andThen(this.interrupt),
|
Effect.onExit(this.f(key), () => SubscriptionRef.set(this.fiber, Option.none())),
|
||||||
Effect.andThen(Result.unsafeForkEffect(this.f(key), { initialProgress: this.initialProgress })),
|
{ initialProgress: this.initialProgress },
|
||||||
|
).pipe(
|
||||||
Effect.tap(([, fiber]) => SubscriptionRef.set(this.fiber, Option.some(fiber))),
|
Effect.tap(([, fiber]) => SubscriptionRef.set(this.fiber, Option.some(fiber))),
|
||||||
Effect.andThen(([sub]) => Effect.all([Effect.succeed(sub), sub.get])),
|
Effect.andThen(([sub]) => Effect.all([Effect.succeed(sub), sub.get])),
|
||||||
Effect.andThen(([sub, initial]) => Stream.runFoldEffect(
|
Effect.andThen(([sub, initial]) => Stream.runFoldEffect(
|
||||||
@@ -53,7 +51,6 @@ extends Pipeable.Class() implements Query<K, A, E, R, P> {
|
|||||||
initial,
|
initial,
|
||||||
(_, result) => Effect.as(SubscriptionRef.set(this.result, result), result),
|
(_, result) => Effect.as(SubscriptionRef.set(this.result, result), result),
|
||||||
)),
|
)),
|
||||||
Effect.tap(SubscriptionRef.set(this.fiber, Option.none())),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user