It is important to note that the reactive blocks are ordered via simple static analysis at compile time, and all the compiler looks at are the variables that are assigned to and used within the block itself, not in any functions called by them. This means that `yDependent` will not be updated when `x` is updated in the following example:
It is important to note that the reactive blocks are ordered via simple static analysis at compile time, and all the compiler looks at are the variables that are assigned to and used within the block itself, not in any functions called by them. This means that `yDependent` will not be updated when `x` is updated in the following example:
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
```svelte
```svelte
<!--- file: App.svelte --->
<script>
<script>
/** @type {import('svelte/action').Action} */
/** @type {import('svelte/action').Action} */
function foo(node) {
function foo(node) {
@ -441,6 +445,7 @@ An action can have a parameter. If the returned value has an `update` method, it
> Don't worry about the fact that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
> Don't worry about the fact that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
```svelte
```svelte
<!--- file: App.svelte --->
<script>
<script>
export let bar;
export let bar;
@ -558,6 +563,7 @@ The `t` argument passed to `css` is a value between `0` and `1` after the `easin
The function is called repeatedly _before_ the transition begins, with different `t` and `u` arguments.
The function is called repeatedly _before_ the transition begins, with different `t` and `u` arguments.
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
```svelte
```svelte
<!--- file: App.svelte --->
<script>
<script>
/** @type {import('svelte/action').Action} */
/** @type {import('svelte/action').Action} */
function foo(node) {
function foo(node) {
@ -26,6 +27,7 @@ An action can have a parameter. If the returned value has an `update` method, it
> Don't worry that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
> Don't worry that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
```svelte
```svelte
<!--- file: App.svelte --->
<script>
<script>
/** @type {string} */
/** @type {string} */
export let bar;
export let bar;
@ -54,6 +56,7 @@ An action can have a parameter. If the returned value has an `update` method, it
Sometimes actions emit custom events and apply custom attributes to the element they are applied to. To support this, actions typed with `Action` or `ActionReturn` type can have a last parameter, `Attributes`:
Sometimes actions emit custom events and apply custom attributes to the element they are applied to. To support this, actions typed with `Action` or `ActionReturn` type can have a last parameter, `Attributes`:
@ -14,7 +14,7 @@ Learn more at the [Svelte website](https://svelte.dev), or stop by the [Discord
You can play around with Svelte in the [tutorial](https://learn.svelte.dev/), [examples](https://svelte.dev/examples), and [REPL](https://svelte.dev/repl).
You can play around with Svelte in the [tutorial](https://learn.svelte.dev/), [examples](https://svelte.dev/examples), and [REPL](https://svelte.dev/repl).
When you're ready to build a full-fledge application, we recommend using [SvelteKit](https://kit.svelte.dev):
When you're ready to build a full-fledged application, we recommend using [SvelteKit](https://kit.svelte.dev):