mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-18 05:25:08 +00:00
update store test
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
import { Store } from 'svelte/store.js';
|
|
||||||
import * as sapper from '@sapper/client';
|
import * as sapper from '@sapper/client';
|
||||||
|
|
||||||
window.start = () => sapper.start({
|
window.start = () => sapper.start({
|
||||||
target: document.querySelector('#sapper'),
|
target: document.querySelector('#sapper')
|
||||||
store: data => new Store(data)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.prefetchRoutes = () => sapper.prefetchRoutes();
|
window.prefetchRoutes = () => sapper.prefetchRoutes();
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
<h1>{$title}</h1>
|
<script>
|
||||||
|
import * as sapper from '@sapper/client';
|
||||||
|
const session = sapper.session();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{$session.title}</h1>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import polka from 'polka';
|
import polka from 'polka';
|
||||||
import { Store } from 'svelte/store.js';
|
|
||||||
import * as sapper from '@sapper/server';
|
import * as sapper from '@sapper/server';
|
||||||
|
|
||||||
const { PORT } = process.env;
|
const { PORT } = process.env;
|
||||||
@@ -12,11 +11,9 @@ polka()
|
|||||||
})
|
})
|
||||||
.use(
|
.use(
|
||||||
sapper.middleware({
|
sapper.middleware({
|
||||||
store: (req, res) => {
|
session: (req, res) => ({
|
||||||
return new Store({
|
title: `${req.hello} ${res.locals.name}`
|
||||||
title: `${req.hello} ${res.locals.name}`
|
})
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.listen(PORT);
|
.listen(PORT);
|
||||||
|
|||||||
Reference in New Issue
Block a user