Created
January 20, 2019 09:55
-
-
Save IhwanID/a2576a7d8b58abf13e4d5ff33ad5584e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package id.ihwan.aac.network | |
import io.reactivex.Observer | |
import io.reactivex.disposables.CompositeDisposable | |
import io.reactivex.disposables.Disposable | |
abstract class ApiObserver<T> constructor(private val compositeDisposable: CompositeDisposable): Observer<T> { | |
override fun onComplete() { | |
} | |
override fun onSubscribe(d: Disposable) { | |
compositeDisposable.add(d) | |
} | |
override fun onNext(t: T) { | |
onApiSuccess(t) | |
} | |
override fun onError(e: Throwable) { | |
onApiError(e) | |
} | |
abstract fun onApiSuccess(data: T) | |
abstract fun onApiError(er: Throwable) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment