File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
packages/svelte/tests/runtime-runes/samples/untrack-own-deriveds Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import { flushSync } from 'svelte' ;
2+ import { test } from '../../test' ;
3+
4+ export default test ( {
5+ test ( { assert, target, logs } ) {
6+ const button = target . querySelector ( 'button' ) ;
7+
8+ flushSync ( ( ) => button ?. click ( ) ) ;
9+
10+ assert . htmlEqual (
11+ target . innerHTML ,
12+ `
13+ <button>increment</button>
14+ <p>1/2</p
15+ `
16+ ) ;
17+
18+ assert . deepEqual ( logs , [ 0 , 0 ] ) ;
19+ }
20+ } ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ class Foo {
3+ value = $state (0 );
4+ double = $derived (this .value * 2 );
5+
6+ constructor () {
7+ console .log (this .value , this .double );
8+ }
9+
10+ increment () {
11+ this .value ++ ;
12+ }
13+ }
14+
15+ let foo = $state ();
16+
17+ $effect (() => {
18+ foo = new Foo ();
19+ });
20+ </script >
21+
22+ <button onclick ={() => foo .increment ()}>increment</button >
23+
24+ {#if foo }
25+ <p >{foo .value }/{foo .double }</p >
26+ {/if }
You can’t perform that action at this time.
0 commit comments