I have this code in my svelte component:
$: {
console.log(dateRange)
formatDataForChart()
.then(data => chartData = data);
}
I want to run FormatDataForChart()
when dateRange
is updated, but i dont actually do anything with dateRange
in this segment (it is used in FormatDataForChart()
). So if i were to remove the console.log here the $: would not run when dateRange
is updated, is there a way for me to make sure it still runs without having a console.log or similar?
To clarify, the same code segment in react i would do like this:
useEffect(() => {
formatDataForChart()
.then(data => chartData = data);
}, [dateRange]);
The only way i can think of “using” dateRange
here is by sending it as a parameter to FormatDataForChart()
, but that also seems kinda dumb. I am new to Svelte and i just hope there is a better way to deal with this.