Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.16 KB

File metadata and controls

43 lines (29 loc) · 1.16 KB
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.

Force Revalidation

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);
});

TypeScript Signature

function revalidate(key?: string | string[] | void, force?: boolean): Promise<void>;