Skip to content

Commit

Permalink
modify watch.md (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
TGlide authored May 17, 2024
1 parent 8c5acef commit ee1475d
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions sites/docs/content/utilities/watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ callback. Svelte provides an `untrack` function, allowing you to specify that a
_shouldn't_ be tracked, but it doesn't provide a way to say that _only certain values_ should be
tracked.

`watch` does exactly that. It accepts a getter function, which returns the dependencies of the effect callback.
`watch` does exactly that. It accepts a getter function, which returns the dependencies of the
effect callback.

## Usage

Expand All @@ -34,16 +35,6 @@ watch(() => count, () => {
);
```

It also accepts an array of sources.

```ts
let age = $state(24);
let name = $state("Thomas");
watch([() => age, () => name], () => {
console.log(`${name} is ${age} years old`);
});
```

The callback receives two arguments: The current value of the sources, and the previous value.

<!-- prettier-ignore -->
Expand Down

0 comments on commit ee1475d

Please sign in to comment.