preface
-
Rxjava
Due to itsChain call based on event flow, simple logic & easy to useThe characteristics of the deepAndroid
Developer welcome.
Making screenshots
If you are not familiar with RxJava, check out Android: a clear and easy-to-understand introduction to RxJava
- Today, Carson will adopt todayThe way of text and textparsing
Rxjava
I hope you’ll enjoy it.
Schematic diagram
directory
Schematic diagram
Definition 1.
-
RxJava
在GitHub
Introduction:
RxJava: A Library for composing Asynchronous and Event-based programs using Observable sequences for the Java VM RxJava is a library that uses observable sequences on the Java VM to compose asynchronous, event-based programsCopy the code
- Conclusion:
RxJava
Is aAsynchronous operation based on event flowIn the library
2. The role
Implementing asynchronous operations
Similar to Android AsyncTask, Handler function
Characteristics of 3.
Since RxJava is used as a chain call based on event flow, it makes RxJava:
- Logic is concise
- To achieve elegant
- Using a simple
More importantly, as the complexity of the program logic increases, it remains simple and elegant
4. Introduction of life examples
I introduce and explain the principle of Rxjava with a life example: a customer comes to a restaurant to eat
Schematic diagram
Schematic diagram
5. Principle introduction
5.1 an overview of the
The Rxjava principle is based on an extended observer pattern with four roles:
role | role | analogy |
---|---|---|
Observable | Generate events | The customer |
An Observer | Receives the event and gives the response action | The kitchen |
Subscribe | Connect the observed with the observer | The waiter |
Event | The carrier of communication between the observed and the observer | dishes |
5.2 Description
Customers go to restaurants to have a meal.
Schematic diagram
Schematic diagram
5.3 summarize
The principles of RxJava can be summarized as follows:
- The observed
(observables)
By subscribing to(Subscribe)
Send events sequentiallyGive the observer(the Observer)
- The observer
(the Observer)
Receive events in sequence& Make the corresponding response action. The details are as follows:
Schematic diagram
At this point, the RxJava principle is finished.
6. Summary
- This paper mainly focuses on
Rxjava
The principle of graphic explanation - I will continue to publish a series of articles on Rxjava 2.0 for Android, including principles, operators, application scenarios, back pressure, and more
Schematic diagram
Thumb up, please! Because your encouragement is the biggest power that I write!
Related articles reading
- Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: create operator Android Rxjava: Android RxJava: A comprehensive tutorial on the functional operators
- Android RxJava application description: (Unconditional) Network request polling Android RxJava application description: (conditional) Network request polling Android RxJava application description: Network request nested callback Android RxJava: merge data source Android RxJava: merge data from disk/memory cache: merge data from disk/memory cache Android RxJava: Network request error reconnection (Retrofit)
Welcome to attentionCarson_HoJane books!
Share the dry things about Android development from time to time, the pursuit of short, flat, fast, but there is no lack of depth.