0.2.1 #26
@@ -1,4 +1,4 @@
|
|||||||
import { Console, Effect, Fiber, Option, Pipeable, Predicate, type Scope, Stream, type Subscribable, SubscriptionRef } from "effect"
|
import { Effect, Fiber, Option, Pipeable, Predicate, type Scope, Stream, type Subscribable, SubscriptionRef } from "effect"
|
||||||
import * as Result from "./Result.js"
|
import * as Result from "./Result.js"
|
||||||
|
|
||||||
|
|
||||||
@@ -34,17 +34,12 @@ extends Pipeable.Class() implements Query<K, A, E, R, P> {
|
|||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly interrupt: Effect.Effect<void, never, never> = Effect.gen(this, function*() {
|
get interrupt(): Effect.Effect<void, never, never> {
|
||||||
yield* Console.log("interrupt called")
|
return Effect.andThen(this.fiber, Option.match({
|
||||||
return Option.match(yield* this.fiber, {
|
onSome: Fiber.interrupt,
|
||||||
onSome: fiber => Effect.gen(function*() {
|
|
||||||
yield* Console.log("interrupting...")
|
|
||||||
yield* Fiber.interrupt(fiber)
|
|
||||||
yield* Console.log("done interrupting.")
|
|
||||||
}),
|
|
||||||
onNone: () => Effect.void,
|
onNone: () => Effect.void,
|
||||||
})
|
}))
|
||||||
})
|
}
|
||||||
|
|
||||||
start(key: K): Effect.Effect<
|
start(key: K): Effect.Effect<
|
||||||
Subscribable.Subscribable<Result.Result<A, E, P>>,
|
Subscribable.Subscribable<Result.Result<A, E, P>>,
|
||||||
@@ -52,9 +47,7 @@ extends Pipeable.Class() implements Query<K, A, E, R, P> {
|
|||||||
Scope.Scope | R
|
Scope.Scope | R
|
||||||
> {
|
> {
|
||||||
return Result.unsafeForkEffect(
|
return Result.unsafeForkEffect(
|
||||||
Effect.onExit(this.f(key), exit => SubscriptionRef.set(this.fiber, Option.none()).pipe(
|
Effect.onExit(this.f(key), () => SubscriptionRef.set(this.fiber, Option.none())),
|
||||||
Effect.andThen(Console.log("exited", exit))
|
|
||||||
)),
|
|
||||||
{ initialProgress: this.initialProgress },
|
{ initialProgress: this.initialProgress },
|
||||||
).pipe(
|
).pipe(
|
||||||
Effect.tap(([, fiber]) => SubscriptionRef.set(this.fiber, Option.some(fiber))),
|
Effect.tap(([, fiber]) => SubscriptionRef.set(this.fiber, Option.some(fiber))),
|
||||||
|
|||||||
Reference in New Issue
Block a user