Book Image

Learning Reactive Programming with Java 8

By : Nickolay Tzvetinov
Book Image

Learning Reactive Programming with Java 8

By: Nickolay Tzvetinov

Overview of this book

Table of Contents (15 chapters)
Learning Reactive Programming with Java 8
About the Author
About the Reviewers

Chapter 8. Resource Management and Extending RxJava

Through the previous chapters, we've learned how to use RxJava's observables. We've been using many different operators and factory methods. The factory methods were the source of various Observable instances with different behavior and origin of their emissions. Using the operators, on the other hand, we've been building complex logic around these observables.

In this chapter, we'll learn how to create our own factory methods, which will be capable of managing their source resources. In order to do that, we'll need a way to manage and dispose of the resources. We've created and used multiple methods like this with source files, HTTP requests, folders, or data in the memory. But some of them don't clean up their resources. For example, the HTTP request observable needs a CloseableHttpAsyncClient instance; we created a method that receives it and left the management of it to the user. The time has come to learn how to manage and clean up...