notify method

Future<bool> notify()

返回是否触发执行

Implementation

Future<bool> notify() async {
  ++repeatNum;
  timer?.cancel();
  if (false == _isRunning && repeatNum >= repeatLimitNum) {
    // 如果没有正在执行,且限制次数满足,则触发执行
    _isRunning = true;
    await onListen.call();
    repeatNum = 0;
    _isRunning = false;
    return true;
  } else {
    timer = Timer(duration, () {
      repeatNum = 0;
    });
    return false;
  }
}