This commit is contained in:
@@ -24,9 +24,9 @@ extends Pipeable.Pipeable {
|
||||
|
||||
readonly run: Effect.Effect<void>
|
||||
fetch(key: K): Effect.Effect<Result.Final<A, E, P>>
|
||||
fetchSubscribable(key: K): Effect.Effect<Subscribable.Subscribable<Result.Result<A, E, P>>, never, Scope.Scope>
|
||||
fetchSubscribable(key: K): Effect.Effect<Subscribable.Subscribable<Result.Result<A, E, P>>>
|
||||
readonly refresh: Effect.Effect<Result.Final<A, E, P>, Cause.NoSuchElementException>
|
||||
readonly refreshSubscribable: Effect.Effect<Subscribable.Subscribable<Result.Result<A, E, P>>, Cause.NoSuchElementException, Scope.Scope>
|
||||
readonly refreshSubscribable: Effect.Effect<Subscribable.Subscribable<Result.Result<A, E, P>>, Cause.NoSuchElementException>
|
||||
|
||||
readonly invalidateCache: Effect.Effect<void>
|
||||
invalidateCacheEntry(key: K): Effect.Effect<void>
|
||||
@@ -85,33 +85,25 @@ extends Pipeable.Class() implements Query<K, A, E, R, P> {
|
||||
return this.interrupt.pipe(
|
||||
Effect.andThen(SubscriptionRef.set(this.latestKey, Option.some(key))),
|
||||
Effect.andThen(this.latestFinalResult),
|
||||
Effect.andThen(previous => Effect.provide(
|
||||
this.startCached(key, Option.isSome(previous)
|
||||
Effect.andThen(previous => this.startCached(key, Option.isSome(previous)
|
||||
? Result.willFetch(previous.value) as Result.Final<A, E, P>
|
||||
: Result.initial()
|
||||
),
|
||||
this.context,
|
||||
)),
|
||||
Effect.andThen(sub => this.watch(sub)),
|
||||
Effect.provide(this.context),
|
||||
)
|
||||
}
|
||||
|
||||
fetchSubscribable(key: K): Effect.Effect<
|
||||
Subscribable.Subscribable<Result.Result<A, E, P>>,
|
||||
never,
|
||||
Scope.Scope
|
||||
> {
|
||||
fetchSubscribable(key: K): Effect.Effect<Subscribable.Subscribable<Result.Result<A, E, P>>> {
|
||||
return this.interrupt.pipe(
|
||||
Effect.andThen(SubscriptionRef.set(this.latestKey, Option.some(key))),
|
||||
Effect.andThen(this.latestFinalResult),
|
||||
Effect.andThen(previous => Effect.provide(
|
||||
this.startCached(key, Option.isSome(previous)
|
||||
Effect.andThen(previous => this.startCached(key, Option.isSome(previous)
|
||||
? Result.willFetch(previous.value) as Result.Final<A, E, P>
|
||||
: Result.initial()
|
||||
),
|
||||
this.context,
|
||||
)),
|
||||
Effect.tap(sub => Effect.forkScoped(this.watch(sub))),
|
||||
Effect.provide(this.context),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -120,34 +112,29 @@ extends Pipeable.Class() implements Query<K, A, E, R, P> {
|
||||
Effect.andThen(Effect.Do),
|
||||
Effect.bind("latestKey", () => Effect.andThen(this.latestKey, identity)),
|
||||
Effect.bind("latestFinalResult", () => this.latestFinalResult),
|
||||
Effect.andThen(({ latestKey, latestFinalResult }) => Effect.provide(
|
||||
this.startCached(latestKey, Option.isSome(latestFinalResult)
|
||||
Effect.andThen(({ latestKey, latestFinalResult }) => this.startCached(latestKey, Option.isSome(latestFinalResult)
|
||||
? Result.willRefresh(latestFinalResult.value) as Result.Final<A, E, P>
|
||||
: Result.initial()
|
||||
),
|
||||
this.context,
|
||||
)),
|
||||
Effect.andThen(sub => this.watch(sub)),
|
||||
Effect.provide(this.context),
|
||||
)
|
||||
}
|
||||
|
||||
get refreshSubscribable(): Effect.Effect<
|
||||
Subscribable.Subscribable<Result.Result<A, E, P>>,
|
||||
Cause.NoSuchElementException,
|
||||
Scope.Scope
|
||||
Cause.NoSuchElementException
|
||||
> {
|
||||
return this.interrupt.pipe(
|
||||
Effect.andThen(Effect.Do),
|
||||
Effect.bind("latestKey", () => Effect.andThen(this.latestKey, identity)),
|
||||
Effect.bind("latestFinalResult", () => this.latestFinalResult),
|
||||
Effect.andThen(({ latestKey, latestFinalResult }) => Effect.provide(
|
||||
this.startCached(latestKey, Option.isSome(latestFinalResult)
|
||||
Effect.andThen(({ latestKey, latestFinalResult }) => this.startCached(latestKey, Option.isSome(latestFinalResult)
|
||||
? Result.willRefresh(latestFinalResult.value) as Result.Final<A, E, P>
|
||||
: Result.initial()
|
||||
),
|
||||
this.context,
|
||||
)),
|
||||
Effect.tap(sub => Effect.forkScoped(this.watch(sub))),
|
||||
Effect.provide(this.context),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user