@netsells/vue-set-timeout
v0.1.5
Published
Use setTimeout and setInterval safely in Vue
Downloads
379
Keywords
Readme
Vue Set Timeout
A mixin to make it easy to safely use setTimeout, setInterval and clearTimeout in your Vue components without memory leaks
Usage
This mixin adds setTimeout, setInterval and clearInterval to the components class instance. They take the same arguments as the native JS functions, and return the same values.
import VueSetTimeout from '@netsells/vue-set-timeout';
export default {
mixins: [VueSetTimeout],
mounted() {
this.setTimeout(() => {}, 10);
const timer = this.setInterval(() => {}, 10);
this.clearTimeout(timer);
},
}