You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
query revalidation, cache invalidation, data refresh
6
5
tags:
7
6
- revalidate
8
7
- cache
9
-
- refresh
10
-
- invalidation
11
-
- polling
12
-
- refetch
8
+
- query
13
9
version: "1.0"
14
10
description: >-
15
-
Manually revalidate cached queries to refresh stale data, implement polling,
16
-
or trigger updates after mutations in SolidJS.
11
+
revalidate retriggers router query cache entries.
17
12
---
18
13
19
-
The `revalidate` function triggers revalidation of [queries](/solid-router/data-fetching/queries) by their keys.
20
-
Each query with active subscribers re-executes and updates its dependents; queries without subscribers are marked stale but don't execute until subscribed.
14
+
`revalidate` retriggers [`query`](/solid-router/reference/data-apis/query) cache entries inside a transition.
21
15
22
16
## Import
23
17
@@ -41,69 +35,92 @@ function revalidate(
41
35
-**Type:**`string | string[] | void`
42
36
-**Required:** No
43
37
44
-
The query key or array of query keys to revalidate.
45
-
If not provided, all queries on the current page are revalidated.
38
+
Cache key or keys from a query function's [`key`](/solid-router/reference/data-apis/query#key) or [`keyFor`](/solid-router/reference/data-apis/query#keyfor) property.
46
39
47
40
### `force`
48
41
49
42
-**Type:**`boolean`
50
-
-**Required:** No
51
43
-**Default:**`true`
44
+
-**Required:** No
52
45
53
-
When `true`, clears the internal cache used for deduplication.
54
-
When `false`, allows cached data to be reused if available.
46
+
When `true`, matching cache entries are marked as cache misses before subscribers are retriggered.
47
+
When `false`, subscribers are retriggered without changing cache entry timestamps.
55
48
56
49
## Return value
57
50
58
-
`revalidate` returns a `Promise` that resolves when the revalidation transition completes.
51
+
-**Type:**`Promise<void>`
52
+
53
+
Resolves when the revalidation transition completes.
- When `key` is undefined, every cache entry matches.
59
+
- A string or array `key` matches cache entries by key prefix. [`query.key`](/solid-router/reference/data-apis/query#key) targets every cached argument set for that query; [`query.keyFor(...)`](/solid-router/reference/data-apis/query#keyfor) targets one serialized argument list.
60
+
- Matching cache entries update their live signal with the current timestamp, retriggering active cache reads through primitives such as [`createAsync`](/solid-router/reference/data-apis/create-async).
61
+
- Without active subscribers, `revalidate` does not call the query function.
Invoke actions programmatically without forms using useAction. Perfect for
15
-
client-side mutations and imperative updates.
11
+
useAction returns a router-bound action caller.
16
12
---
17
13
18
-
The `useAction` primitive returns a function that triggers an [action](/solid-router/concepts/actions) when called.
19
-
20
-
`useAction` requires client-side JavaScript and is not progressively enhanceable.
14
+
`useAction` returns a function that calls an [`action`](/solid-router/reference/data-apis/action) with the current router context. It is the programmatic caller for non-form submissions.
21
15
22
16
## Import
23
17
@@ -40,25 +34,36 @@ function useAction<T extends Array<any>, U, V>(
40
34
-**Type:**`Action<T, U, V>`
41
35
-**Required:** Yes
42
36
43
-
The action to be triggered.
37
+
[`Action`](/solid-router/reference/data-apis/action) to bind to the current router.
44
38
45
39
## Return value
46
40
47
-
`useAction` returns a function that triggers the action.
48
-
It takes the same parameters as the action handler and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with the action's result.
41
+
-**Type:**`(...args: Parameters<Action<T, U, V>>) => Promise<NarrowResponse<U>>`
42
+
43
+
Returns a router-bound caller with the same arguments as `action`.
44
+
45
+
## Behavior
46
+
47
+
- Unlike native form submissions, calls made with `useAction` depend on client-side JavaScript.
0 commit comments