Skip to content

Commit

Permalink
1.修改AndroidSubscriber可以单独不进行处理统一错误回调
Browse files Browse the repository at this point in the history
  • Loading branch information
keep2iron committed Jun 8, 2019
1 parent 48b5493 commit 76e741a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import io.reactivex.disposables.Disposable
* 请在application中初始化这个方法
*/
open class AndroidSubscriber<T>(
private val useGlobalOnError: Boolean = true,
private inline val onSuccess: ((resp: T) -> Unit)? = null,
private inline val onError: ((throwable: Throwable) -> Unit)? = null
) : Observer<T>, Subscriber<T> {
Expand All @@ -37,7 +38,9 @@ open class AndroidSubscriber<T>(
@CallSuper
override fun onError(throwable: Throwable) {
Log.e(NetworkManager.TAG, Log.getStackTraceString(throwable))
NetworkManager.doOnError(throwable)
if(useGlobalOnError) {
NetworkManager.doOnError(throwable)
}
onError?.invoke(throwable)
}

Expand Down

0 comments on commit 76e741a

Please sign in to comment.