@raf-query/react 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -6
- package/README.md +18 -8
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/devtools-panel.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.1](https://github.com/KATT/raf-query/compare/0.1.0...0.1.1) (2026-10-12)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **core:** add predicate to QueryFilter ([#24](https://github.com/KATT/raf-query/issues/24)) ([c0b9c18](https://github.com/KATT/raf-query/commit/c0b9c1829cb3b6446f765b151e520f0195af5276))
|
|
8
|
+
|
|
3
9
|
## [0.1.0](https://github.com/KATT/raf-query/compare/0.0.19...0.1.0) (2026-10-12)
|
|
4
10
|
|
|
5
11
|
### ⚠ BREAKING CHANGES
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
- Effect-native engine; core exposes only Effect APIs ([#23](https://github.com/KATT/raf-query/issues/23))
|
|
14
|
+
- **core:** make QueryObserver an Effect-style data type ([#29](https://github.com/KATT/raf-query/issues/29))
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
- **core:** make QueryObserver an Effect-style data type ([#29](https://github.com/KATT/raf-query/issues/29)) ([50fbb45](https://github.com/KATT/raf-query/commit/50fbb45bf3edcaa83673e2177894a76bdf76560b))
|
|
17
|
+
- Effect-native engine; core exposes only Effect APIs ([#23](https://github.com/KATT/raf-query/issues/23)) ([8e0bb09](https://github.com/KATT/raf-query/commit/8e0bb09a63d644ede053f443406a521ff2613a6f))
|
|
12
18
|
|
|
13
19
|
### Features
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
- **core:** stream SSR dehydration as Effect APIs; integrations become thin edges ([#30](https://github.com/KATT/raf-query/issues/30)) ([6b2b570](https://github.com/KATT/raf-query/commit/6b2b5703f5463c0f3805c233cf4ead90df9efb76)), references [#29](https://github.com/KATT/raf-query/issues/29)
|
|
22
|
+
- typed services for Effect queries; QueryClient layer and dispose() ([#31](https://github.com/KATT/raf-query/issues/31)) ([6aeaa3d](https://github.com/KATT/raf-query/commit/6aeaa3d356f6483654729620ac26762508eb8fd8))
|
|
17
23
|
|
|
18
24
|
## [0.0.19](https://github.com/KATT/raf-query/compare/0.0.18...0.0.19) (2026-10-12)
|
|
19
25
|
|
package/README.md
CHANGED
|
@@ -358,12 +358,22 @@ function EditTitle(props: { post: Post }) {
|
|
|
358
358
|
|
|
359
359
|
`updatePost` is a server function (or a Next.js server action). `await qc.invalidate(...)` resolves once every query currently being read has refetched, so the action's pending state lasts until the fresh data is on screen. For an error message, wrap the action in `useActionState` and return the caught error.
|
|
360
360
|
|
|
361
|
-
| Call | Effect
|
|
362
|
-
| ------------------------------------- |
|
|
363
|
-
| `qc.invalidate(factory, input)` | Mark one query stale and refetch it if it is being read
|
|
364
|
-
| `qc.invalidate(
|
|
365
|
-
| `qc.setData(factory, input, updater)` | Write data directly
|
|
366
|
-
| `qc.getData(factory, input)` | Read cached data, or `undefined`
|
|
361
|
+
| Call | Effect |
|
|
362
|
+
| ------------------------------------- | ------------------------------------------------------- |
|
|
363
|
+
| `qc.invalidate(factory, input)` | Mark one query stale and refetch it if it is being read |
|
|
364
|
+
| `qc.invalidate(filter)` | Same, for every query the [filter](#filters) selects |
|
|
365
|
+
| `qc.setData(factory, input, updater)` | Write data directly |
|
|
366
|
+
| `qc.getData(factory, input)` | Read cached data, or `undefined` |
|
|
367
|
+
|
|
368
|
+
### Filters
|
|
369
|
+
|
|
370
|
+
`invalidate`, `reset` and `remove` also take a filter, `{ queryKey?, exact?, predicate? }`. `queryKey` selects every query whose key starts with it, or only that key with `exact: true`; object segments match partially, so `{ queryKey: ["issues", { projectId: 3 }] }` selects every issue list in project 3. `predicate` gets each remaining `Query` and keeps the ones it returns `true` for: read its `key` and `handle.input`, or use the `Query` functions (`Query.getUnsafe(query)` for its state, `Query.observerCountUnsafe(query)`, `Query.isStaleUnsafe(query)`). Without `queryKey` every key matches, so `{}` selects the whole cache.
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
qc.remove({ predicate: (query) => Query.observerCountUnsafe(query) === 0 }); // everything not being read
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
`handle.input` is the input of the latest factory call for that entry. An entry that was only hydrated, and not yet read or started on this client, has `undefined` input, so match on `key` to include those.
|
|
367
377
|
|
|
368
378
|
Data can be `undefined` when the `queryFn`'s type allows it (`Promise<User | undefined>`); it's cached and reused like any other value, unlike in TanStack Query, where an `undefined` result is an error. So `getData` and an updater's `previous` return `undefined` both with no data and with `undefined` data; `Query.getUnsafe(qc.getQuery(factory, input)).hasData` tells them apart.
|
|
369
379
|
|
|
@@ -598,8 +608,8 @@ Both render nothing on the server, since the server's cache isn't the browser's.
|
|
|
598
608
|
| `new QueryClient(config?)` | `config.defaults` (query options below), `config.onError`, `config.isServer`, `config.layer` ([services](#services)) |
|
|
599
609
|
| `prefetch`, `ensure`, `fetch` | [Start queries](#starting-queries) |
|
|
600
610
|
| `invalidate`, `setData`, `getData` | [Write and read the cache](#mutations) |
|
|
601
|
-
| `reset(factory, input)` / `reset(filter)` | Drop data and errors; read queries suspend and refetch. Resolves when they settle
|
|
602
|
-
| `remove(factory, input)` / `remove(filter)` | Remove entries and abort their requests
|
|
611
|
+
| `reset(factory, input)` / `reset(filter)` | Drop data and errors; read queries suspend and refetch. Resolves when they settle. [Filters](#filters) |
|
|
612
|
+
| `remove(factory, input)` / `remove(filter)` | Remove entries and abort their requests. [Filters](#filters) |
|
|
603
613
|
| `effect` | The [Effect](#effect) `QueryCache` behind the client |
|
|
604
614
|
| `subscribe(listener)` | Cache events: `added`, `updated`, `observers` (a reader subscribed or left), `removed`, and `failed` (with the `error`) |
|
|
605
615
|
| `getAll()`, `getQuery(factory, input?)` | Cache entries, for devtools and integrations |
|
package/dist/client.d.mts
CHANGED
|
@@ -46,7 +46,7 @@ export declare class QueryClient<TServices = never> {
|
|
|
46
46
|
/**
|
|
47
47
|
* Mark queries stale and refetch the ones being read. Resolves once those
|
|
48
48
|
* refetches settle, so an action stays pending until fresh data is on
|
|
49
|
-
* screen. Takes a factory and its input, or a {@link
|
|
49
|
+
* screen. Takes a factory and its input, or a {@link QueryCache.Filter}.
|
|
50
50
|
*/
|
|
51
51
|
invalidate<TFactory extends QueryFactory<TServices>>(...target: QueryCache.Target<TFactory>): Promise<void>;
|
|
52
52
|
/**
|
package/dist/client.mjs
CHANGED
|
@@ -66,7 +66,7 @@ var QueryClient = class {
|
|
|
66
66
|
/**
|
|
67
67
|
* Mark queries stale and refetch the ones being read. Resolves once those
|
|
68
68
|
* refetches settle, so an action stays pending until fresh data is on
|
|
69
|
-
* screen. Takes a factory and its input, or a {@link
|
|
69
|
+
* screen. Takes a factory and its input, or a {@link QueryCache.Filter}.
|
|
70
70
|
*/
|
|
71
71
|
invalidate(...target) {
|
|
72
72
|
return Effect.runPromise(this.effect.invalidate(...target));
|
package/dist/devtools-panel.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raf-query/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React bindings for raf-query, a render-as-you-fetch query library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"./tanstack-router": "./dist/tanstack-router.mjs"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@raf-query/core": "0.1.
|
|
43
|
+
"@raf-query/core": "0.1.1",
|
|
44
44
|
"effect": "^4.0.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|