【RxJava】Introduction to RxJava (RxJava Concept | RxJava Composition - Observer / Observer / Subscription / Operator | RxJava Applicable Scenarios)





1. Introduction to RxJava




1. RxJava concept


The RxJava framework is an asynchronous programming function library , which includes the following elements:

  • Observer pattern
  • iterator pattern
  • functional programming

RxJava framework application scenarios:

  • asynchronous operation
  • event flow

2. Composition of RxJava - Observer/Observer/Subscription/Operator


RxJava components:

  • Observable (observed): Observable is a data source that can send messages. It can send several messages at the same time. The format of the message can be defined by generics; the observer will be notified after the message is sent. Observable implements message observers.

  • Observer (observer): Observer represents an observer who receives messages sent by Observable. It handles messages emitted from Observables, and also handles error and completion events.

  • Subscription (subscription): Subscription is the binding of Observer to Observable, which means that the observer is receiving the data items of Observable. Subscriptions can be cancelled. After unsubscribing, the Observer will no longer receive messages from the Observable.

  • Operator: Operators are used to process and transform Observable messages sent by observers . Operations such as filtering, transforming, merging, and combining of messages can be performed ;


3. Applicable scenarios of RxJava


RxJava calls/chains the observer/observer/subscription/operator elements through combination ;

RxJava can simplify the process of asynchronous programming and event processing , and provide elegant /combinable/extensible solutions.

RxJava also supports thread switching/concurrent processing/error handling , which is good for handling various concurrent and asynchronous operations.


The RxJava asynchronous programming library contains the idea of ​​responsive programming and provides a concise, flexible and composable way to process asynchronous tasks and event flows.


RxJava can play a huge role in the following application scenarios:

  • Android development
  • Java backend service
  • Responsive UI
  • Java application development

Guess you like

Origin blog.csdn.net/han1202012/article/details/130690312