#Watch value modified inside the watch
35 messages · Page 1 of 1 (latest)
because the api call could be call from multiple components
but maybe i should do it like that, anyway i found this solution :
watch (experiments, (newExperiments) => {
for (let i = 0; i < newExperiments.length; i++) {
newExperiments[i].create_time = new Date(newExperiments[i].create_time).toDateString();
}
experiments.value = newExperiments;
loading.value = false
triggerTaskExperiments.value++
})
Who is working for what i need
But maybe not the better one
I have another problem who is related more or less, let me explain :
Here is my onMounted : ```js
onMounted(() => {
nextTick(() => {
getExperiments()
})
})
This trigger the watch : ```js
watch (experiments, (newExperiments) => {
for (let i = 0; i < newExperiments.length; i++) {
newExperiments[i].create_time = new Date(newExperiments[i].create_time).toDateString();
}
experiments.value = newExperiments;
loading.value = false
triggerTaskExperiments.value++
})
``` who does triggerTaskExperiments.value++
and the dates should be the same for all entries?
this already looks a bit strange 😄
Then in my template i have : ```js
<TaskExperiments ref="task" :key="triggerTaskExperiments" :test="triggerTaskExperiments" :experiments="experiments" :infoUpload="infoUpload" v-on:refresh-task="receiveTaskRefresh" />
And receiveTaskRefresh function who actually is : ```js
function receiveTaskRefresh(info) {
analysis = info.analysis
}
And here what i got :
yes, it should be formated always like that
for all the entries
Ahah you can tell me more ? 🫣
I should do the format next after the response is received are you telling ? 🙂
I've placed a console.log in receiveTaskRefresh function who is called by @refresh-task and it doesn't display
So i'm never inside this function, actually i'm not fully understanding how it should be triggering, or launched, it is related with the :key and :test props on the component ?
i found the @v-on on the docs but nothing about the refresh_task on the @v-on:refresh_task, it is something we can call whatever we want ?
But anyway, it was working before i was changing all the SFC from OptionsAPI to CompositionAPI, so it should be working 😦
well, you have to trigger that event in your component
there is no "built-in" refresh_task function
but the function name come after the v-on:refresh-task="hereIsTheFunctionCalled" no ?
refresh-task is the event ?
What would be the way to do that ?