Minimalist design
Provide users with the simplest and most direct development experience
Thanks for vue-demi, it works for both Vue 2 & 3.
npm i vue-composition-toolset
import { useTimerFn } from 'vue-composition-toolset'
export default {
setup() {
const doSomething = () => {
/* your function */
}
const { trigger } = useTimerFn(doSomething, 30 * 1000) // The function will be executed every 30 seconds
trigger.value = false // Disable the timer that executes the function
trigger.value = true // Enable the timer that executes the function
}
}
MIT License © 2021-PRESENT leafstark