Skip to content

Commit

Permalink
add some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 15, 2024
1 parent d42cade commit 3900db0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions documentation/docs/02-runes/07-$inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,20 @@ A convenient way to find the origin of some change is to pass `console.trace` to
// @errors: 2304
$inspect(stuff).with(console.trace);
```

## $inspect.trace(...)

This rune, added in 5.14, causes the surrounding function to be _traced_ in development. Any time the function re-runs as part of an [effect]($effect), information will be printed to the console about which pieces of reactive state caused the effect to fire.

This comment has been minimized.

Copy link
@trueadm

trueadm Dec 15, 2024

Contributor

or derived


```svelte
<script>
import { doSomeWork } from './elsewhere';
$effect(() => {
+++$inspect.trace();+++
doSomeWork();
});
</script>
```

`$inspect.trace` takes an optional first argument which will be used as the label.

0 comments on commit 3900db0

Please sign in to comment.