官术网_书友最值得收藏!

When to use RxJava

A common question ReactiveX newcomers ask is what circumstances warrant a reactive approach? Do we always want to use RxJava? As someone who has been living and breathing reactive programming for a while, I have learned that there are two answers to this question:

The first answer is when you first start out: yes! You always want to take a reactive approach. The only way to truly become a master of reactive programming is to build reactive applications from the ground up. Think of everything as Observable and always model your program in terms of data and event flows. When you do this, you will leverage everything reactive programming has to offer and see the quality of your applications go up significantly.

The second answer is that when you become experienced in RxJava, you will find cases where RxJava may not be appropriate. There will occasionally be times where a reactive approach may not be optimal, but usually, this exception applies to only part of your code. Your entire project itself should be reactive. There may be parts that are not reactive and for good reason. These exceptions only stand out to a trained Rx veteran who sees that returning List<String> is perhaps better than returning Observable<String>.

Rx greenhorns should not worry about when something should be reactive versus something not reactive. Over time, they will start to see cases where the benefits of Rx are marginalized, and this is something that only comes with experience.

So for now, no compromises. Go reactive all the way!

主站蜘蛛池模板: 新化县| 二连浩特市| 新晃| 高台县| 灵宝市| 库车县| 苏尼特右旗| 将乐县| 永善县| 伊宁市| 绥棱县| 湟中县| 农安县| 松溪县| 沁源县| 屏南县| 库车县| 墨竹工卡县| 浙江省| 开远市| 资中县| 通道| 通化县| 阜宁县| 苏尼特右旗| 西畴县| 怀集县| 张家界市| 八宿县| 上杭县| 奇台县| 嘉禾县| 紫阳县| 吴堡县| 新沂市| 灯塔市| 和平区| 会泽县| 宜阳县| 成安县| 盖州市|