fengyuanchen / vue-countdown

Countdown component for Vue.js.
https://fengyuanchen.github.io/vue-countdown/
MIT License
690 stars 89 forks source link

Detect which component called method "@progress"? #48

Closed Proadik closed 3 years ago

Proadik commented 4 years ago

I have several components in my table with different times to count to. The problem is i need to send request to server every second, so the time as I refresh will change to correct time. (deadlines functionality)

Here is my code:

<div class="table-row" :key="task.id" v-for="(task, id) in tasks">
   <div class="task-deadlines">
      <countdown :time="task.seconds" @progress="handleCountdownProgress" :auto-start='true'>
      <template slot-scope="props">{{ props.days }} д. {{ props.hours }} ч. {{ props.minutes }} м. {{ props.seconds }} с.</template>
      </countdown>
   </div>
</div>

Method:

handleCountdownProgress(data){
   let time = data.totalMilliseconds;
   // cant get an id here...
   this.$store.dispatch('UPDATE_TIME', { id: id, seconds: time });
}

Is there any way to do this?