RxJava overview, RxJava
RxJava explanation for Android Developers: http://gank.io/post/560e15be2dca930e00da1083
Responsive programming is a programming paradigm of asynchronous data stream interaction. RxJava is a library implemented on Java based on event-based asynchronous data stream.
The core idea is to treat everything as data streams, various variables, user input, data structure, cache, etc.
The Rx Library provides highly abstract functions for stream operations, such as creation, inbound and outbound, filtering, merging, and ing.
In addition, the Rx Library also simplifies asynchronous operations and error handling.
The obvious advantage after RxJava is used is
1 solved the problem of callback hell (that is, many layers of callback nesting ).
2. Convenient thread Switching
3. With the new feature of Java 8, mongolambda, the code will be further concise
The deeper advantage is to deepen the code abstraction so that we can focus more on the business logic rather than the specific implementation details.
In addition, the event-driven system can be decoupled into multiple components, enabling better code scalability and fault tolerance.
But there are also some difficulties
1. to make good use of responsive programming, We must train stream-based programming thinking, which is quite different from the past.
This will make it difficult to refactor the code in the past, and often write "semi-finished products" because the thinking is not pure"
2 because the operators in the Rx library are highly abstract, it is very convenient to use, but the cost of in-depth understanding is very high.
3 because the Rx library is very abstract and young, there will be many pitfalls to be aware of during use, and Lambda will bring some performance impact.