Hello everyone, I've posted a question on stackove...
# rx
k
Hello everyone, I've posted a question on stackoverflow around Flowable, Rx, Kotlin, Retrofit2. Thanks to take a look if you can 👍 https://stackoverflow.com/questions/45441074/multiple-retrofit2-requests-using-flowable-in-kotlin 1 reply this is how i would solve it:
Copy code
Flowable.zip<User, Comments, Pair<User, Comments>>(
      postService.getUser(postId),
      postService.getCommentsByPostId(postId),
      BiFunction { user, comments -> Pair(user, comments) })
      .subscribeOn(<http://Schedulers.io|Schedulers.io>())
      .map { (first, second) -> Triple(first, second, ExtraDatas()) }
      .subscribe({
        Log.d("MainActivity", "OnNext")
      }, {
        Log.d("MainActivity", "OnError")
      }, {
        Log.d("MainActivity", "OnComplete")
      })
Use the
zip
or
zipWith
functions to achieve your goal if the retrofit2 calls dont depent on each other. You can find out more here: http://reactivex.io/documentation/operators/zip.html after that map the data from the server with the mainActivity data together. Thats easy as well and finally Kotlin has a very beautiful syntax for labdas so i would encourage you to use them with the specific subscribe function: http://reactivex.io/RxJava/javadoc/io/reactivex/Flowable.html#subscribe(io.reactivex.functions.Consumer,%20io.reactivex.functions.Consumer,%20io.reactivex.functions.Action)