throttleFunction static method

void throttleFunction(
  1. Function fn, {
  2. int milliseconds = 1000,
})

防重复提交, 默认一秒【节流】

Implementation

static void throttleFunction(Function fn, {int milliseconds = 1000}) {
  throttleBehaviorSubject.add(null);
  if (throttleBehaviorSubject.hasListener == false) {
    throttleBehaviorSubject
        .throttleTime(Duration(milliseconds: milliseconds))
        .listen((value) {
      fn.call();
    });
  }
}