configureDefers function
void
configureDefers({})
Configures how to execute a deferred task.
Note: onActionDone and onError are available if it is caused by
the invocation of flushDefers. That is, they are passed from
the arguments when calling flushDefers.
executor- if specified, it is used to executetask. Otherwise,taskwas called directly.executable- if specified, it will be called before executing a task. And, if it returns null, the task will be executed as normal. On the other hand, if it returns a duration,deferwill pause the given duration and then start over again. It is usually to defer the execution further when the system is busy.maxBusy- how long to wait before forcing a new execution to start if there is an execution of the samekeystill executing. Default: null (forever). When a task is about to execute, we'll check if the previous execution is done. If not, it will wait the time specified inmaxBusy.
Note: the signature of task: FutureOr task(key).
Thus, you must pass key to it when calling task(key).
Implementation
void configureDefers(
{FutureOr executor(key, Function task, String? category,
{void onActionDone()?, void onError(Object ex, StackTrace st)?})?,
Duration? executable(int runningCount)?, Duration? maxBusy}) {
_executor = executor;
_executable = executable;
_maxBusy = maxBusy;
}