export default {
  methods: {
    interval(cb, time) {
      let timer = setInterval(cb, time);
      const clearTimer = () => {
        if (timer) {
          clearInterval(timer);
          timer = null;
        }
      };
      this.$once("hook:beforeDestroy", clearTimer);
      this.$once("hook:deactivated", clearTimer);
      return clearTimer;
    },
  },
};
