configureDefers function

void configureDefers({
  1. FutureOr executor(
    1. dynamic key,
    2. Function task,
    3. String? category, {
    4. void onActionDone()?,
    5. void onError(
      1. dynamic ex,
      2. StackTrace st
      )?,
    })?,
  2. Duration? executable(
    1. int runningCount
    )?,
  3. Duration? maxBusy,
})

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 execute task. Otherwise, task was 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, defer will 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 same key still 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 in maxBusy.

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(ex, StackTrace st)?})?,
     Duration? executable(int runningCount)?, Duration? maxBusy}) {
  _executor = executor;
  _executable = executable;
  _maxBusy = maxBusy;
}