Skip to content

Commit ec2f963

Browse files
committed
Added unsubscribeUntilDetach with error handling.
1 parent c81912e commit ec2f963

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/kotlin/com/mvcoding/mvp/Presenter.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ abstract class Presenter<VIEW : Presenter.View> {
3333
}
3434

3535
protected fun <T> Observable<T>.subscribeUntilDetached(onNext: (T) -> Unit) = subscribe(onNext).apply { unsubscribeOnDetach(this) }
36+
protected fun <T> Observable<T>.subscribeUntilDetached(onNext: (T) -> Unit, onError: (Throwable) -> Unit) =
37+
subscribe(onNext, onError).apply { unsubscribeOnDetach(this) }
3638

3739
private fun ensureViewIsNotAttached(view: VIEW) {
3840
if (this.view != null) throw IllegalStateException("Cannot attach $view, because ${this.view} is already attached")

0 commit comments

Comments
 (0)