1

I'm new to rx-java, I'm comming from the akka world. In akka-streams there is a convinient intersperse function and I would like to know how to do the same on Flowable? so something like

Flowable
 .fromIterable(List("foo","bar"))
 .intersperse("[", "," ,"]")

which would output: [foo,bar]

I have a some big data streamed from a DB to convert as a JSON array and that would be super useful.

currently I found:

Flowable....
   .startWith(Flowable.just("["))
   .concatWith(Flowable.just("]"))

Don't know if it's a clean way, but now I just miss the in between comma

Edit: I have a working solution with

Flowable....
   .concatMap(str => Flowable.just(str, ",")
   .skipLast(1) 
   .startWith(Flowable.just("["))
   .concatWith(Flowable.just("]"))

But still, it seems it could be easier no?

0 Answers0