diff --git a/.changeset/ninety-tables-switch.md b/.changeset/ninety-tables-switch.md new file mode 100644 index 000000000000..37bd6b1f8937 --- /dev/null +++ b/.changeset/ninety-tables-switch.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[breaking] call `invalidate(fn)` predicates with a URL instead of a string diff --git a/.changeset/rude-nails-work.md b/.changeset/rude-nails-work.md new file mode 100644 index 000000000000..e11a00cbf10b --- /dev/null +++ b/.changeset/rude-nails-work.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[breaking] replace invalidate() with invalidateAll() diff --git a/.changeset/shiny-vans-jam.md b/.changeset/shiny-vans-jam.md new file mode 100644 index 000000000000..84664ebdbab8 --- /dev/null +++ b/.changeset/shiny-vans-jam.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +Use `invalidateAll()` diff --git a/documentation/docs/05-load.md b/documentation/docs/05-load.md index eb83c9111ec0..0aaf5389dffc 100644 --- a/documentation/docs/05-load.md +++ b/documentation/docs/05-load.md @@ -99,12 +99,14 @@ An instance of [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL), co #### depends -This function declares that the `load` function has a _dependency_ on one or more URLs, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun. +This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun. Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`. URLs can be absolute or relative to the page being loaded, and must be [encoded](https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding). +Custom identifiers have to be prefixed with one or more lowercase letters followed by a colon to conform to the [URI specification](https://www.rfc-editor.org/rfc/rfc3986.html) + ```js // @filename: ambient.d.ts declare module '$lib/api' { @@ -121,7 +123,11 @@ import * as api from '$lib/api'; /** @type {import('./$types').PageLoad} */ export async function load({ depends }) { - depends(`${api.base}/foo`, `${api.base}/bar`); + depends( + `${api.base}/foo`, + `${api.base}/bar`, + 'my-stuff:foo' + ); return { foo: api.client.get('/foo'), diff --git a/packages/create-svelte/templates/default/src/lib/form.ts b/packages/create-svelte/templates/default/src/lib/form.ts index c38dee6ec094..6723c612f5de 100644 --- a/packages/create-svelte/templates/default/src/lib/form.ts +++ b/packages/create-svelte/templates/default/src/lib/form.ts @@ -1,4 +1,4 @@ -import { invalidate } from '$app/navigation'; +import { invalidateAll } from '$app/navigation'; // this action (https://svelte.dev/tutorial/actions) allows us to // progressively enhance a