-
-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2.x] Refactor
createInertiaApp
in Svelte adapter (#2036)
* Refactor state management * Move SSR logic to user-land * Toggle "removeComments" TS option back to true * Fix type error
- Loading branch information
1 parent
c8228f0
commit a95409f
Showing
14 changed files
with
200 additions
and
109 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
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
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { derived } from 'svelte/store' | ||
import store from './store' | ||
import { type Page } from '@inertiajs/core' | ||
import { writable } from 'svelte/store' | ||
|
||
const page = derived(store, ($store) => $store.page) | ||
const { set, subscribe } = writable<Page>() | ||
|
||
export default page | ||
export const setPage = set | ||
|
||
export default { subscribe } |
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
packages/svelte/test-app/Pages/Svelte/PropsAndPageStore.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,41 @@ | ||
<script> | ||
import { inertia, page, router, useForm } from '@inertiajs/svelte' | ||
import { onMount } from 'svelte' | ||
export let foo | ||
const form = useForm({ foo }) | ||
console.log('[script] foo prop is', foo) | ||
console.log('[script] $page.props.foo is', $page.props.foo) | ||
$: console.log('[reactive expression] foo prop is', foo) | ||
$: console.log('[reactive expression] $page.props.foo is', $page.props.foo) | ||
onMount(() => { | ||
console.log('[onMount] foo prop is', foo) | ||
console.log('[onMount] $page.props.foo is', $page.props.foo) | ||
}) | ||
</script> | ||
|
||
<div> | ||
<input id="input" type="text" bind:value={$form.foo}> | ||
<p>foo prop is {foo}</p> | ||
<p>$page.props.foo is {$page.props.foo}</p> | ||
|
||
<a | ||
href="/svelte/props-and-page-store" | ||
use:inertia={{ data: { foo: 'bar' } }} | ||
> | ||
Bar | ||
</a> | ||
<a | ||
href="/svelte/props-and-page-store" | ||
use:inertia={{ data: { foo: 'baz' } }} | ||
> | ||
Baz | ||
</a> | ||
<a href="/" use:inertia> | ||
Home | ||
</a> | ||
</div> |
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
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
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
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
Oops, something went wrong.