0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
svelte/documentation/tutorial/02-reactivity/01-reactive-assignments/text.md

22 lines
568 B
Markdown
Raw Normal View History

2019-03-10 14:30:29 +01:00
---
title: Assignments
---
At the heart of Svelte is a powerful system of _reactivity_ for keeping the DOM in sync with your application state — for example, in response to an event.
2019-03-10 14:30:29 +01:00
To demonstrate it, we first need to wire up an event handler. Replace line 9 with this:
```svelte
2021-06-26 20:23:30 +02:00
<button on:click={incrementCount}>
2019-03-10 14:30:29 +01:00
```
2021-06-26 20:23:30 +02:00
Inside the `incrementCount` function, all we need to do is change the value of `count`:
2019-03-10 14:30:29 +01:00
```js
2021-06-26 20:23:30 +02:00
function incrementCount() {
2019-03-10 14:30:29 +01:00
count += 1;
}
```
2021-06-26 20:23:30 +02:00
Svelte 'instruments' this assignment with some code that tells it the DOM will need to be updated.