throttle static method
节流
Implementation
static Function throttle(
Function() func, {
String? id,
int timeout = _defaultDuration,
Function? funcWhenComplete,
}) {
return () {
final String key = id ?? func.hashCode.toString();
final bool enable = _funcThrottle[key] ?? true;
if (enable) {
_funcThrottle[key] = false;
Timer(Duration(milliseconds: timeout), () {
_funcThrottle.remove(key);
});
func.call();
}
};
}