npm.io
0.1.1 • Published 5 years ago

vue-timing-events

Licence
MIT
Version
0.1.1
Deps
2
Size
9 kB
Vulns
1
Weekly
0

Vue Timing Events License Library size Dependencies

Automatically cleans up timers and event listeners on component beforeDestroy

Install

$ npm install -D vue-timing-events

# For Yarn, use the command below.
yarn add vue-timing-events

Usage

import Vue from "vue";
import VueTimingEvents from 'vue-timing-events';

Vue.use(VueTimingEvents);
// Somecomponent.vue
export default {
  created() {
    this.$setInterval(this.doInterval, 2000);
    this.$addEventListener("resize", this.onResize, { passive: true });
  },
  methods: {
    doInterval() {
      console.log("Are we there yet?");
    },
    onResize() {
      console.log("Hey stop triggering so much layout/reflow. :(");
    }
  }
}

License

MIT Danny Pham

Keywords