site: reactive statements, avoid infinite loops

Add a blurb to describe how reactive statements can be configured to run only when certain values have changed.
pull/3962/head
Steven Huang 6 years ago committed by GitHub
parent 0aceccc31b
commit f7d5892fa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -130,6 +130,23 @@ Any top-level statement (i.e. not inside a block or a function) can be made reac
--- ---
To avoid infinite loops, reactive statements can be configured to run only when certain values have changed.
```html
<script>
export let x, y, z;
function dosomething() {
z = x + y;
}
// this will execute `dosomething()` whenever
// `x` or `y` prop changes, but not `z`
$: x, y, dosomething();
</script>
```
---
If a statement consists entirely of an assignment to an undeclared variable, Svelte will inject a `let` declaration on your behalf. If a statement consists entirely of an assignment to an undeclared variable, Svelte will inject a `let` declaration on your behalf.
```html ```html

Loading…
Cancel
Save