| title | revalidate |
|---|
Revalidate will receive the either a cache key or an array of cache keys and invalidate those queries.
:::tip[Firing Queries Again] If you intend to re-fire the queries immediately, check the reload helper. :::
The code below will revalidate the getTodo query with the cache key.
import { action, revalidate } from "@solidjs/router";
const updateTodo = action(async (todo: Todo) => {
await putTodo(todo.id, todo);
return revalidate(getTodo.keyFor());
});To better understand how queries work, check the query documentation.
The revalidate function also accepts a second parameter to force the revalidation of the cache data.
import { action, revalidate } from "@solidjs/router";
const updateTodo = action(async (todo: Todo) => {
await putTodo(todo.id, todo);
return revalidate(getTodo.keyFor(), true);
});function revalidate(key?: string | string[] | void, force?: boolean): Promise<void>;