-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ability to invalidate a custom identifier on goto() (#13256)
closes #10659 --------- Co-authored-by: Tee Ming <[email protected]> Co-authored-by: Simon H <[email protected]>
- Loading branch information
1 parent
a91ba1f
commit 04958cc
Showing
8 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': minor | ||
--- | ||
|
||
feat: add ability to invalidate a custom identifier on `goto()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('./$types').LayoutLoad} */ | ||
export function load({ depends }) { | ||
depends('invalidate-depends-goto:layout'); | ||
return { | ||
layout: new Date().getTime() | ||
}; | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('./$types').PageLoad} */ | ||
export function load({ data, depends }) { | ||
depends('invalidate-depends-goto:shared'); | ||
return { | ||
shared: new Date().getTime(), | ||
...data | ||
}; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('./$types').PageServerLoad} */ | ||
export function load({ depends }) { | ||
depends('invalidate-depends-goto:server'); | ||
return { | ||
server: new Date().getTime() | ||
}; | ||
} |
49 changes: 49 additions & 0 deletions
49
packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script> | ||
import { goto } from '$app/navigation'; | ||
import { page } from '$app/state'; | ||
/** @type {import('./$types').PageData} */ | ||
export let data; | ||
</script> | ||
|
||
<p class="layout">{data.layout}</p> | ||
<button | ||
type="button" | ||
class="specified" | ||
on:click={() => | ||
(window.promise = goto(page.url.pathname, { | ||
invalidate: ['invalidate-depends-goto:layout', 'invalidate-depends-goto:shared'] | ||
}))} | ||
> | ||
invalidate specified | ||
</button> | ||
|
||
<p class="server">{data.server}</p> | ||
<button | ||
type="button" | ||
class="server" | ||
on:click={() => | ||
(window.promise = goto(page.url.pathname, { invalidate: ['invalidate-depends-goto:server'] }))} | ||
> | ||
invalidate server | ||
</button> | ||
|
||
<p class="shared">{data.shared}</p> | ||
<button | ||
type="button" | ||
class="shared" | ||
on:click={() => | ||
(window.promise = goto(page.url.pathname, { invalidate: ['invalidate-depends-goto:shared'] }))} | ||
> | ||
invalidate shared | ||
</button> | ||
|
||
<p class="neither">neither</p> | ||
<button | ||
type="button" | ||
class="neither" | ||
on:click={() => | ||
(window.promise = goto(page.url.pathname, { invalidate: ['invalidate-depends-goto:neither'] }))} | ||
> | ||
invalidate neither | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters