tap<A> function
- void f(
- A
Transforms a task into another task after performing a side effect.
Example:
Task<int> sampleTask = Task<int>(() => Future.value(10));
Task<int> newTask = tap<int>((value) => print(value))(sampleTask); // Prints the result and returns the same task.
Implementation
TapFunction<A> tap<A>(void Function(A) f) {
return (Task<A> task) {
task.task().then(f).catchError((_) {});
return task;
};
}