When todos
or showCompleted
change, visibleTodos
will be updated.
Svelte by Example: Reactive Statements
Reactive statements can be used to derive computed data or trigger side effects when something changes. Statements prefixed with a $:
label are reactive. They'll be recomputed when data used in the reactive statement is updated.
In this example, we'll add a toggle to show or hide completed todos.
Reactive statements can also be used to trigger side effects.
Multiple statements can be grouped in a reactive block.
resources://
Further reading on this topic.