Posts

Showing posts with the label observable

Merging Rx Single Results

Today, I saw something incredible which basically looks like this. public class Thing { final ThingService thingService ; public Thing ( final ThingService thingService) { this . thingService = thingService ; } public Single<List<String>> getOtherThings ( final List<String> keys ) { return keys.stream() .map(key -> getOtherThing(key)) .reduce( Single. just (Collections. emptyList ()) , (singleThing1 , singleThing2) -> singleThing1 .flatMap(thing1 -> singleThing2 .map(thing2 -> { final List<String> newList = new LinkedList<>( thing1 ) ; newList.addAll(thing2) ; return newList ; })) ) ; } } public class ThingService { public Single<List<Strin...