let timer = null;
let count = 0;
Component({
  props: {
    delayTime: '1000',
    totalCount: 10,
    onFunCallBack: () => null,
    onStartFun: () => null
  },
  data: {},

  didUnmount() {
    clearInterval(timer);
    timer = null;
    count = 0;
  },

  didMount() {
    this.pollFun();
  },

  methods: {
    pollFun() {
      const {
        onStartFun,
        onFunCallBack,
        delayTime,
        totalCount
      } = this.props;

      if (!timer) {
        timer = setInterval(async () => {
          count += 1;

          if (count > totalCount) {
            clearInterval(timer);
            timer = null;
            count = 0;
            onFunCallBack();
          }

          onStartFun();
        }, delayTime);
      }
    }

  }
});