You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/store-assignment-updates-pr.../main.svelte

24 lines
447 B

<script>
import { writable } from '../../../../store';
const a = writable({ foo: 1, bar: 2 });
$a.foo = 3;
const b = writable({ foo: 1, bar: 2 });
$b = { foo: 3 };
function update() {
$a.foo = $a.foo + 1;
$b = { foo: $b.foo + 1, qux: 0 };
}
</script>
<p>a: {JSON.stringify($a)}</p>
<p>b: {JSON.stringify($b)}</p>
<button on:click={() => {
$a.foo = $a.foo + 1;
$b = { foo: $b.foo + 1, baz: 0 };
}} />
<button on:click={update} />