-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Describe the bug
When referencing a $derived rune from a class instance in the $effect rune. The effect is not triggered, on change, when that value is a boolean.
Reproduction
<script>
import {someLogic} from './SomeLogic.svelte';
function increment() {
someLogic.trigger();
}
let lokalDerived = $derived(someLogic.someValue > 3);
$effect(() => {
console.log(someLogic.someValue);
});
$effect(() => {
// Does not trigger
console.log('class trigger', someLogic.isAboveThree)
});
$effect(() => {
// Does Triggers
console.log('lokal trigger', lokalDerived)
});
</script>
<button on:click={increment}>
clicks: {someLogic.someValue}
<!-- Adding this line below, will make the effect above trigger as i should -->
<!-- has clicked more then 3 times {someLogic.isAboveThree} -->
</button>class SomeLogic {
someValue = $state(0);
isAboveThree = $derived(this.someValue > 3)
trigger(){
this.someValue++;
}
}
export const someLogic = new SomeLogic();REPL: Tap the clicks button 4 times and have a look at the log.
Logs
No response
System Info
REPLSeverity
annoyance