qingmei2 / rxweaver Goto Github PK
View Code? Open in Web Editor NEW:baby_chick: 一种基于RxJava2实现全局Error处理的实现方式。
Home Page: https://www.jianshu.com/p/eb10d6e40c4b
:baby_chick: 一种基于RxJava2实现全局Error处理的实现方式。
Home Page: https://www.jianshu.com/p/eb10d6e40c4b
GlobalErrorTransformer.java
AndroidSchedulers::mainThread
用过compose操作符的人都应该知道这种 XXXTransformer 思路
请求成功的success info 与 请求失败的error info 对用户来说都是data,严格来说应该统一在main thread下的 subscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError)里指定callback就行,特别是 throwable,在ui层成判断哪些信息是需要友好展现给用户的,哪些是需要抛弃的(在debug调试阶段状态下打印出来), 在中途把error信息抛出来,很容易出现在子线程上下文内去回调执行ui逻辑,这一点很容易让使用者陷入误区,同时应该避免在 upstream和downstream之间来回线程切换,项目明显用java实现后可读性更好,用kotlin去糊一道,完全是玩的心态....
这几天仔细把这个库看完了,我现在处理使用map来处理服务端返回的异常,如果code不匹配,直接throw一个,这样代码量就更少,也好理解(相比使用flatmap)。然后今天用公司的接口实践,结果错误都返回400,然后OnNextInterceptor里面都拿不到错误信息,全部都堆再onError里面去了,难受
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.