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 'svelte': patch
--- ---
feat: adds $log rune feat: add $log rune

@ -168,7 +168,7 @@ declare namespace $log {
export function trace(): void; 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 * ```ts
* $log.table(someDataCollection) * $log.table(someDataCollection)

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

Loading…
Cancel
Save