mirror of https://github.com/sveltejs/svelte
fix: ensure toStore subscription correctly syncs latest value (#14015)
* fix: ensure toStore subscription correctly syncs latest value * Update packages/svelte/src/store/index-client.js --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/14035/head
parent
0106204982
commit
435a9c1cd0
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure toStore subscription correctly syncs latest value
|
@ -0,0 +1,6 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `1`,
|
||||||
|
mode: ['client', 'hydrate']
|
||||||
|
});
|
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
import { toStore } from 'svelte/store';
|
||||||
|
|
||||||
|
let count = $state(0);
|
||||||
|
|
||||||
|
const store = toStore(
|
||||||
|
() => count,
|
||||||
|
(v) => (count = v)
|
||||||
|
);
|
||||||
|
|
||||||
|
store.set(1);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{$store}
|
Loading…
Reference in new issue