add method
Adds a handler
to the queue that processes the previous value.
The buffer
duration can be used to throttle the execution.
Implementation
FutureOr<void> add(
FutureOr<void> Function() handler, {
Duration? buffer,
_TOnPrevErr<T>? onPrevErr,
bool? eagerError,
}) {
final result = addSafe(
(_) {
final value = handler();
switch (value) {
case Future():
return Async(() async {
// TODO: false positive linter!
// ignore: no_futures_allowed
await value;
return const None();
});
default:
return syncNone();
}
},
buffer: buffer,
onPrevErr: onPrevErr,
eagerError: eagerError,
).value;
if (result is Future<Result<Option<T>>>) {
return result.then<void>((e) {
if (e.isErr()) {
throw e;
}
});
} else {
if (result.isErr()) {
throw result;
}
}
}