Java Magazine, Jan/Feb 2018
USE CASE NUMBER OF EXPECTED ITEMS ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 35 reactive programming RxJava The Reactive Programming Toolbox for Java Lets focus on reactive programming a development model for writing asynchronous code When using reactive programming the code manipulates streams of data The data is generated by publishers The data flows between a publisher and consumers which process the data Consumers observing a data stream are notified when a new item is available when the stream completes and when an error is caught To avoid overloading consumers a back pressure protocol is required to control the amount of data flowing in the stream This is generally handled transparently by the reactive framework There are several implementations of the reactive programming paradigm RxJava is a straightforward implementation of reactive extensions RX for the Java programming language It is a popular library for reactive programming that can be used to develop applications in networked data processing graphical user interfaces with JavaFX and Android apps RxJava is the principal toolkit for reactive libraries in Java and it provides five data types to describe data publishers depending on the types of data streams as shown in Table 1 These types represent data publishers and convey data processed by consumers observing them Depending on the number of items flowing in the stream the type is diferent For streams with a bounded or unbounded sequence of items the types Observable and Flowable are used The difference between Observable and Flowable is that Flowable handles back pressure that is it implements a reactive streams protocol while Observable does not Flowable is better IN THE STREAM Table 1 RxJava reactive publisher types RXJAVA TYPES NOTIFICATION DATA FLOW 0 N Observable Flowable ASYNCHRONOUS OPERATION PRODUCING 1 1 MAYBE A RESULT 0 1 Single Maybe ASYNCHRONOUS OPERATION THAT DOES NOT PRODUCE A RESULT 0 Completable
You must have JavaScript enabled to view digital editions.