Skip to content

Commit 3900db0

Browse files
committed
add some docs
1 parent d42cade commit 3900db0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

documentation/docs/02-runes/07-$inspect.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,20 @@ A convenient way to find the origin of some change is to pass `console.trace` to
4242
// @errors: 2304
4343
$inspect(stuff).with(console.trace);
4444
```
45+
46+
## $inspect.trace(...)
47+
48+
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.
49+
50+
```svelte
51+
<script>
52+
import { doSomeWork } from './elsewhere';
53+
54+
$effect(() => {
55+
+++$inspect.trace();+++
56+
doSomeWork();
57+
});
58+
</script>
59+
```
60+
61+
`$inspect.trace` takes an optional first argument which will be used as the label.

0 commit comments

Comments
 (0)