Skip to content

Commit d69272f

Browse files
committed
Added unsubscribeUntilDetach with onComplete handling.
1 parent aef2f92 commit d69272f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

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

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

40+
protected fun <T> Observable<T>.subscribeUntilDetached(onNext: (T) -> Unit, onError: (Throwable) -> Unit, onComplete: () -> Unit) =
41+
subscribe(onNext, onError, onComplete).apply { unsubscribeOnDetach(this) }
42+
3943
private fun ensureViewIsNotAttached(view: VIEW) {
4044
if (this.view != null) throw IllegalStateException("Cannot attach $view, because ${this.view} is already attached")
4145
}

0 commit comments

Comments
 (0)