Romain Romain - 1 year ago 94
Java Question

Call void method and pass trought arguments RxJava

I'm looking for a better to do this :

mRestService.login(email, password) // Login user in
.flatMap(user ->
mRestService.start(user._token), // Start his session
(v, u) -> (User) u // Pass user throught
.subscribe(user -> {
}, throwable -> {

But I coudn't come up with something better.

Answer Source

the start method on the mRestService perform a side effect. So you can use doOnNext method which is here for this sort of side effect.

 mRerstService.login(email, password)
              .doOnNext(u -> mRestService.start(user._token))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download