throttle method
Throttle function When an event is triggered, the target operation is executed immediately, and then the event is only responded to after the asynchronous method completes execution.
Implementation
Function throttle() {
bool enable = _vxfuncThrottle[hashCode] ?? true;
void func() {
if (enable) {
_vxfuncThrottle[hashCode] = false;
this.call().then((_) {
_vxfuncThrottle[hashCode] = false;
}).whenComplete(() {
_vxfuncThrottle.remove(hashCode);
});
}
}
func();
return func;
}