run static method
Schedules the execution of onExecute after duration.
If another call to run with the same tag occurs
within duration, the previous scheduled execution
is cancelled and the new one is scheduled.
If duration is Duration.zero, the callback is executed immediately.
Implementation
static void run(
String tag,
Duration duration,
void Function() onExecute,
) {
if (duration == Duration.zero) {
_operations[tag]?.timer.cancel();
_operations.remove(tag);
onExecute();
} else {
_operations[tag]?.timer.cancel();
_operations[tag] = _NakiDebounceData(
onExecute,
Timer(duration, () => fire(tag)),
);
}
}