mirror of https://github.com/sveltejs/svelte
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.
24 lines
447 B
24 lines
447 B
4 years ago
|
<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} />
|