My Question is probably more of the conceptual nature.
I get that by the Observable
contract my Observable
will not emit any more items after onComplete
or onError
is called.
But I'm using the RxBindings for Android and therefore it's not "my Observable
" but the click on a Button
that emits items.
fun observeForgotPasswordButton(): Disposable {
return view.observeForgotPasswordButton()
.flatMap {
authService.forgotPassword(email).toObservable<Any>()
}
.subscribe({
// on next
Timber.d("fun: onNext:")
}, { error ->
// on error
Timber.e(error, "fun: onError")
}, {
// onComplete
Timber.d("fun: onComplete")
})
}
observeForgotPasswordButton()
returns an Observable
fun observeForgotPasswordButton(): Observable<Any> = RxView.clicks(b_forgot_password)
The problem is that authService.forgotPassword(email)
is a Completable
and it will call either onComplete
or onError
both of which lead to the fact that I cannot reuse the button anymore since the subscription ended.
Is there a way to circumvent this behavior?
Because in an error occurs I would like to be able to retry.
Also I would like it to be possible to send more then one password forgotten emails.
flatMapCompletable
– maspauthService
instead of callingonNext
with an error state. This is the rx-way... – grAPPfruitrookie
mistake. Even Square's Retrofit did that once. – Phoenix Wang