in todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/statistics/domain/StatisticsLogic.java [48:62]
public static Next<StatisticsState, StatisticsEffect> update(
StatisticsState state, StatisticsEvent event) {
return event.map(
tasksLoaded -> {
ImmutableList<Task> tasks = tasksLoaded.tasks();
int activeCount = 0;
int completedCount = 0;
for (Task task : tasks) {
if (task.details().completed()) completedCount++;
else activeCount++;
}
return next(loaded(activeCount, completedCount));
},
tasksLoadingFailed -> next(failed()));
}