Creating a web component using svelte, I need to run some code when an attribute of the component is changed.
What I have come up with is the following pattern.
<script>
export let test = "default value";
$: {
testIsChanged(test);
}
function testIsChanged(newValue) {
console.log(newValue);
}
</script>
The value of test is {test}
Is this the way to do it? Or am I missing something?