Skip to content

Commit

Permalink
Added Completable
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarnagiris committed Jul 10, 2018
1 parent ea6d715 commit 65a73b7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mvp/src/main/kotlin/com/mvcoding/mvp/Presenter.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.mvcoding.mvp

import io.reactivex.Flowable
import io.reactivex.Maybe
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.*
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

Expand Down Expand Up @@ -56,11 +53,13 @@ abstract class Presenter<VIEW : Presenter.View>(private vararg val behaviors: Be
protected fun <T> Flowable<T>.subscribeUntilDetached(): Disposable = subscribe().apply { disposeOnDetach(this) }
protected fun <T> Single<T>.subscribeUntilDetached(): Disposable = subscribe().apply { disposeOnDetach(this) }
protected fun <T> Maybe<T>.subscribeUntilDetached(): Disposable = subscribe().apply { disposeOnDetach(this) }
protected fun Completable.subscribeUntilDetached(): Disposable = subscribe().apply { disposeOnDetach(this) }

protected fun <T> Observable<T>.subscribeUntilDetached(onNext: (T) -> Unit): Disposable = subscribe(onNext).apply { disposeOnDetach(this) }
protected fun <T> Flowable<T>.subscribeUntilDetached(onNext: (T) -> Unit): Disposable = subscribe(onNext).apply { disposeOnDetach(this) }
protected fun <T> Single<T>.subscribeUntilDetached(onSuccess: (T) -> Unit): Disposable = subscribe(onSuccess).apply { disposeOnDetach(this) }
protected fun <T> Maybe<T>.subscribeUntilDetached(onSuccess: (T) -> Unit): Disposable = subscribe(onSuccess).apply { disposeOnDetach(this) }
protected fun Completable.subscribeUntilDetached(onComplete: () -> Unit): Disposable = subscribe(onComplete).apply { disposeOnDetach(this) }

protected fun <T> Observable<T>.subscribeUntilDetached(onNext: (T) -> Unit, onError: (Throwable) -> Unit): Disposable =
subscribe(onNext, onError).apply { disposeOnDetach(this) }
Expand All @@ -74,6 +73,9 @@ abstract class Presenter<VIEW : Presenter.View>(private vararg val behaviors: Be
protected fun <T> Maybe<T>.subscribeUntilDetached(onSuccess: (T) -> Unit, onError: (Throwable) -> Unit): Disposable =
subscribe(onSuccess, onError).apply { disposeOnDetach(this) }

protected fun Completable.subscribeUntilDetached(onComplete: () -> Unit, onError: (Throwable) -> Unit): Disposable =
subscribe(onComplete, onError).apply { disposeOnDetach(this) }

protected fun <T> Observable<T>.subscribeUntilDetached(onNext: (T) -> Unit, onError: (Throwable) -> Unit, onComplete: () -> Unit): Disposable =
subscribe(onNext, onError, onComplete).apply { disposeOnDetach(this) }

Expand Down

0 comments on commit 65a73b7

Please sign in to comment.