Refactor QueryClient
Lint / lint (push) Successful in 26s

This commit is contained in:
Julien Valverdé committed 2026-10-09 02:18:02 +02:00
1 parent 3875bc4f69
commit acb05fce44
5 files changed
+7 -6

No files matched your search

+1 -1
View File
@@ -39,7 +39,7 @@ import { Layer } from "effect"
import { QueryClient, ReactRuntime } from "effect-view"
const AppLive = Layer.empty.pipe(
Layer.provideMerge(QueryClient.layer({
Layer.provideMerge(QueryClient.layerWithOptions({
defaultStaleTime: "30 seconds",
defaultRefreshOnWindowFocus: true,
cacheGcTime: "5 minutes",
+2 -2
View File
@@ -21,7 +21,7 @@ import { Layer } from "effect"
import { QueryClient, ReactRuntime } from "effect-view"
const AppLive = Layer.empty.pipe(
Layer.provideMerge(QueryClient.layer({
Layer.provideMerge(QueryClient.layerWithOptions({
defaultStaleTime: "30 seconds", // default: "0 minutes"
defaultRefreshOnWindowFocus: true, // default: true
cacheGcTime: "5 minutes", // default: "5 minutes"
@@ -30,7 +30,7 @@ const AppLive = Layer.empty.pipe(
export const runtime = ReactRuntime.make(AppLive)
```
`QueryClient.layer(options?)` builds the service and forks its background garbage-collection loop into the layer's scope. Individual queries may override `staleTime`/`refreshOnWindowFocus`; unset options fall back to these client defaults. `cacheGcTime` controls how long a stale, unaccessed cache entry is kept before eviction. You interact with the client only indirectly through `Query` instances — no need to call `QueryClientService` methods directly.
`QueryClient.layer` (defaults) / `QueryClient.layerWithOptions(options)` build the service and fork its background garbage-collection loop into the layer's scope. Individual queries may override `staleTime`/`refreshOnWindowFocus`; unset options fall back to these client defaults. `cacheGcTime` controls how long a stale, unaccessed cache entry is kept before eviction. You interact with the client only indirectly through `Query` instances — no need to call `QueryClientService` methods directly.
## Create and run a query
+1 -1
View File
@@ -9,7 +9,7 @@ import * as View from "./View.js"
const runQueryTest = <A, E>(effect: Effect.Effect<A, E, QueryClient.QueryClient | Scope.Scope>) =>
Effect.runPromise(Effect.scoped(effect.pipe(
Effect.provide(QueryClient.layer()),
Effect.provide(QueryClient.layer),
)))
const staticKey = <K>(key: K): View.View<K> => View.make({
+2 -1
View File
@@ -122,7 +122,8 @@ export const thenRun = <E = never, R = never>(
client => Effect.forkScoped(client.run),
)
export const layer = (options?: make.Options) => Layer.effect(QueryClient, thenRun(make(options)))
export const layer = Layer.effect(QueryClient, thenRun(make()))
export const layerWithOptions = (options: make.Options) => Layer.effect(QueryClient, thenRun(make(options)))
export const QueryClientCacheKeyTypeId: unique symbol = Symbol.for("@effect-view/QueryClient/QueryClientCacheKey")
+1 -1
View File
@@ -5,7 +5,7 @@ import { QueryClient, ReactRuntime } from "effect-view"
export const layer = Layer.empty.pipe(
Layer.provideMerge(QueryClient.layer()),
Layer.provideMerge(QueryClient.layer),
Layer.provideMerge(DateTime.layerCurrentZoneLocal),
Layer.provideMerge(Clipboard.layer),
Layer.provideMerge(Geolocation.layer),