Merge branch 'log-rune' of github.com:sveltejs/svelte into log-rune

log-rune
Rich Harris 10 months ago
commit e7d5cd6b6a

@ -2,4 +2,4 @@
'svelte': patch
---
feat: adds $log rune
feat: add $log rune

@ -168,7 +168,7 @@ declare namespace $log {
export function trace(): void;
/**
* Deeply tracks and `console.table`s any values passed to the rune. Example:
* Logs the arguments with `console.table` whenever they change. Example:
*
* ```ts
* $log.table(someDataCollection)

@ -267,9 +267,9 @@ export default {
## `$log`
The `$log` rune is roughly equivalent to `console.log`, with the exception that when anything passed to the
rune changes, the latest values will be logged out. `$log` tracks reactive state deeply, meaning that mutating
something from with an object or array using fine-grain reactivity will be tracked.
The `$log` rune is roughly equivalent to `console.log`, with the exception that it will re-run whenever the
arguments change. `$log` tracks reactive state deeply, meaning that updating something inside an object
or array using [fine-grained reactivity](/docs/fine-grained-reactivity) will update the logs.
```svelte
<script>
@ -313,9 +313,8 @@ This works just like `$log`, but triggers `console.table` instead of `console.lo
## `$log.trace`
This works just like `$log`, but in addition to logging the values, it will also trace
any mutations to fine-grain reactive state and log the sourcecode location to help find
the cause for something changing.
This works just like `$log`, but in addition to logging the values themselves it will pinpoint the
line of code that triggered the update.
```svelte
<script>

Loading…
Cancel
Save