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