Reputation: 27574
I want to emit a final item after all the items in the Flowable
are emitted. For now I can achieve this via the following code.
Flowable<String> flowable = getFlowable();
flowable.toList()
.toFlowable()
.flatMap(stringList -> {
stringList.add("final String");
return Flowable.just(stringList);
})
.subscribe(System.out::println);
The problem is, it waits until all the items are obtained before emitting. I want them to be emitted immediately when they are obtained, one at a time, and an extra final String
could be emitted right after the last item, how to achieve that?
Upvotes: 0
Views: 293
Reputation: 32016
You can use concatWith
flowable.concatWith(Flowable.just(stringList))
.subscribe(System.out::println);
Upvotes: 2