Closed as not planned
Description
Describe the problem
Currently code like this
<script>
let counter = $state(0);
function increment(e,entity) {
entity++;
}
</script>
<div>{counter}</div>
<button onclick={() => { increment(event,counter) } }>Increment</button>
passes just the value without the reactivity.
Describe the proposed solution
I believe the ability to pass the reactivity reference enables a good practice to be able to decouple methods and state which improves re-usability and dependency and gives more freedom.
Probably something like
<script>
import { ref } from 'svelte/reactive';
let counter = $state(0);
function increment(e,entity) {
// here entity should be the " let counter " reactive state and it should increment the state value
entity++;
}
</script>
<div>{counter}</div>
<button onclick={ () => { increment(event, ref(counter)) } }>Increment</button>
or whatever solution is suitable that may bring the feature available and keep default behavior unaffected
Importance
i cannot use svelte without it
Metadata
Assignees
Labels
No labels
Activity