Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Created January 20, 2019 09:55
Show Gist options
  • Save IhwanID/a2576a7d8b58abf13e4d5ff33ad5584e to your computer and use it in GitHub Desktop.
Save IhwanID/a2576a7d8b58abf13e4d5ff33ad5584e to your computer and use it in GitHub Desktop.
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