addWait<T> method
void
addWait<T>(
- Future<
T> future, { - required dynamic onSuccess(
- T result
- dynamic onError(
- dynamic e,
- dynamic s
Add operation to list and remove when is finish
Implementation
void addWait<T>(
Future<T> future, {
required Function(T result) onSuccess,
Function(dynamic e, dynamic s)? onError,
}) {
CancelableOperation<T> operation = CancelableOperation.fromFuture(future);
add(operation);
int index = indexOf(operation);
this[index].value.then((result) {
onSuccess(result);
removeAt(index);
}).catchError((e, s) {
onError?.call(e, s);
removeAt(index);
});
}