enqueue<T> method
Future<T>
enqueue<
T>( - Future<T> task(), {
- Duration autoComplete = const Duration(seconds: 5),
- bool catchError = true,
})
Implementation
Future<T> enqueue<T>(
Future<T> Function() task, {
Duration autoComplete = const Duration(seconds: 5),
bool catchError = true,
}) {
final uuid = Uuid().v4();
add(uuid, autoComplete: autoComplete);
return task().catchError((error, stacktrace) {
if (catchError) {
return catchErrorWithStackTrace(error, stacktrace);
} else {
return error;
}
}).whenComplete(
() => complete(uuid),
);
}