Open History to see the last commit
1<script lang="ts">
2 import { untrack } from 'svelte'
3 import { TanStackDevtoolsSvelteAdapter } from './devtools.svelte.js'
4 import type { TanStackDevtoolsSvelteInit } from './types'
5β
6 let { plugins, config, eventBusConfig }: TanStackDevtoolsSvelteInit = $props()
7β
8 let hostEl: HTMLDivElement
9β
10 const adapter = new TanStackDevtoolsSvelteAdapter()
11β
12 // Mount exactly once. We `untrack` the props so this effect does not re-run
13 // (and tear down + rebuild the entire devtools core) whenever a prop changes
14 // β prop changes are handled reactively by the `update` effect below.
15 $effect(() => {
16 adapter.mount(
17 hostEl,
18 untrack(() => ({ plugins, config, eventBusConfig })),
19 )
20β
21 return () => {
22 adapter.destroy()
23 }
24 })
25β
26 // Reactively push config/plugin changes into the existing core instance.
27 $effect(() => {
28 adapter.update({ plugins, config, eventBusConfig })
29 })
30</script>
31β
32<div bind:this={hostEl}></div>