Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
let sum_0 = 0
let sum_1
let sum_2

// $: sum_2 = parseInt(sum_1) + 1 // ok, no matter the order! -> first command
// $: sum_1 = parseInt(sum_0) + 1 // ok, no matter the order! -> second command
const update_sum_1 = () => sum_1 = parseInt(sum_0) + 1
const update_sum_2 = () => sum_2 = parseInt(sum_1) + 1
// $: update_sum_1(sum_0) // this works OK
// $: update_sum_2(sum_1) //

$: update_sum_2(sum_1) // FAILS with svelte 4, OK if switched -> first command
$: update_sum_1(sum_0) // FAILS with svelte 4, OK if switched -> second command
</script>
sum_0: <input bind:value={sum_0}><br />
sum_1: {sum_1}<br />
sum_2: {sum_2}<br />

loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */