Tweak reactive explanation

pull/5729/head
Adam Rackis 5 years ago
parent 4cc468a615
commit df1a441095

@ -130,20 +130,28 @@ Any top-level statement (i.e. not inside a block or a function) can be made reac
--- ---
Only values which directly appear within the `$:` block will become dependencies of the reactive statement. For example, in the code below `total` will only update when `x` or `y` change, but not `z`. Only values which directly appear within the `$:` block will become dependencies of the reactive statement. For example, in the code below `total` will only update when `x` changes, but not `y`.
```sv ```sv
<script> <script>
let x = 0; let x = 0;
let y = 0; let y = 0;
let z = 0;
function updateTotal(x, y) { function yPlusAValue(value) {
return x + y + z; return value + y;
} }
$: total = updateTotal(x, y); $: total = yPlusAValue(x);
</script> </script>
Total: {total}
<button on:click={() => x++}>
Increment X
</button>
<button on:click={() => y++}>
Increment Y
</button>
``` ```
--- ---

Loading…
Cancel
Save