Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,33 @@ class Todo {

> In this example, the compiler transforms `done` and `text` into `get`/`set` methods on the class prototype referencing private fields

Objects and arrays [are made reactive](/#H4sIAAAAAAAAE42QwWrDMBBEf2URhUhUNEl7c21DviPOwZY3jVpZEtIqUBz9e-UUt9BTj7M784bdmZ21wciq48xsPyGr2MF7Jhl9-kXEKxrCoqNLQS2TOqqgPbWd7cgggU3TgCFCAw-RekJ-3Et4lvByEq-drbe_dlsPichZcFYZrT6amQto2pXw5FO88FUYtG90gUfYi3zvWrYL75vxL57zfA07_zfr23k1vjtt-aZ0bQTcbrDL5ZifZcAxKeS8lzDc8X0xDhJ2ItdbX1jlOZMb9VnjyCoKCfMpfwG975NFVwEAAA==):
Objects and arrays [are made deeply reactive](/#H4sIAAAAAAAAA22P3W6DMAyFX8WKJjWoEW23OwZIe46mFwTcNQySiJhJE827TyGV9iOuLJ9jn89e2FUP6FlxXphpRmQFe3OOCUZfLjb-EwdCJpi389RGpfTtpB3V0kgakMCqHip48tQQ8iWqkgx6wq6ARyvJzKPCyRdwPgl4FvBySU6IJWSv0pSHn1xTqpnImmha0w66_agWnkFVpy2r-jwh8kdw7mZ_4xv6gOadbrCHUxakWffjaOQlxm8e_IXBFsc6noWUY93_GLcay8Zeb7XhO9jDLoP7HY4BKtiam7CbW-TpT94IUOslDexBiaQeY4nflAdXM8FG2-mrxo4VNM0YLuEb3K_i5NQBAAA=):

```svelte
<script>
let numbers = $state([1, 2, 3]);
let obj = $state({
nested: {
numbers: [1, 2, 3]
}
});
</script>

<button onclick={() => numbers.push(numbers.length + 1)}>
<button
onclick={() =>
obj.nested.numbers.push(obj.nested.numbers.length + 1)}
>
push
</button>

<button onclick={() => numbers.pop()}> pop </button>
<button onclick={() => obj.nested.numbers.pop()}>
pop
</button>

<p>
{numbers.join(' + ') || 0}
=
{numbers.reduce((a, b) => a + b, 0)}
{obj.nested.numbers.join(' + ') || 0} = {obj.nested.numbers.reduce(
(a, b) => a + b,
0
)}
</p>
```

Expand Down