M
M
movsumlu2020-10-23 12:50:36
Vue.js
movsumlu, 2020-10-23 12:50:36

How to call a method every 5 minutes in a VueJS component?

I understand that everything is quite easy to do through setTimeout, I wanted to clarify the details.
Whether to delete it in beforeDestroy, in what hook it is better to call it and how to make it "beautiful" so to speak?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-10-23
@movsumlu

created() {
  const interval = setInterval(this.method, 5 * 60 * 1000);
  this.$on('hook:beforeDestroy', () => clearInterval(interval));
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question