Answer the question
In order to leave comments, you need to log in
What is the best way to make two requests with RxJava?
I need to implement registration, authorization in the application, and after successful registration, I need to log in. For network request I use Retrofit. How can I better implement using chains in RxJava or without or what is the best, please recommend.
Answer the question
In order to leave comments, you need to log in
//Функция регистрации
fun registration(args: Array<String>) {
compositeDisposable.add(
retofit.registrate(args)
.subscribe({
//User successful registered
//Do auth
authorization(args)
}, {
handleError(it)
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
)
}
//Функция авторизации
fun authorization(args: Array<String>) {
compositeDisposable.add(
retofit.auth(args)
.subscribe({
//User successful auth
//Do work after user auth
userSuccessfulAuth()
}, {
handleError(it)
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question