Chapter 3: Reactive Statements
So far, we've learned that Svelte is able to compile regular variable assignments inside components into something that will automatically update the view. Whenever you assign something to a variable, Svelte will notice that and schedule a rerender for the next browser paint. We then had a closer look at the component syntax to see how to add dynamic behavior to our HTML code. In this chapter, we’ll focus on the contents of the <script>
tag and take a look at how we can run other code in reaction to a variable change.
Have you ever needed to react to a variable change? Probably every day, in some form or the other. Svelte already reacts nicely to changes of variables by rerendering the view. But what if we need ...
Get Svelte: A Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.