These are chat archives for ReactiveX/RxJava

16th
Mar 2017
DavidMihola
@DavidMihola
Mar 16 2017 07:54
@devharis Yes, that seems reasonable - one alternative would be to just put a for loop into the map of your original code, thus transforming a List<Assignment> to a new List<Assignment>.
Haris Kljajić
@devharis
Mar 16 2017 12:54
I don' think that would work because those lists aren't of same type so the return type would not be correct?
AssignmentDTO is the type which the list is of, then we map them to a new list of type Assignment
        return mRetrofit.create(AssignmentService.class).GET("token")
                .flatMapIterable(assignmentDTOs -> {
                    List<Assignment> assignments = new ArrayList<>();
                    for(AssignmentDTO assignmentDTO : assignmentDTOs)
                        assignments.add(mTransformer.transform(assignmentDTO, Assignment.class));

                    return assignments;
                })
                .flatMap(mAssignmentLocalDataStore::add)
                .toList();
Did you mean something like this @DavidMihola ?
DavidMihola
@DavidMihola
Mar 16 2017 16:20
@devharis Yes, that's what I in mind, I just got the types wrong: the input to map is List<AssignmentDTO> and not List<Assignment>. I assume the last snippet works?