mirror of https://github.com/sveltejs/svelte
commit
954eb8d839
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': minor
|
|
||||||
---
|
|
||||||
|
|
||||||
feat: allow state created in deriveds/effects to be written/read locally without self-invalidation
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: simplify set calls for proxyable values
|
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, target, logs }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
|
||||||
|
flushSync(() => button?.click());
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>increment</button>
|
||||||
|
<p>1/2</p
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(logs, [0, 0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
<script>
|
||||||
|
class Foo {
|
||||||
|
value = $state(0);
|
||||||
|
double = $derived(this.value * 2);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
console.log(this.value, this.double);
|
||||||
|
}
|
||||||
|
|
||||||
|
increment() {
|
||||||
|
this.value++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let foo = $state();
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
foo = new Foo();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => foo.increment()}>increment</button>
|
||||||
|
|
||||||
|
{#if foo}
|
||||||
|
<p>{foo.value}/{foo.double}</p>
|
||||||
|
{/if}
|
||||||
Loading…
Reference in new issue