Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Reactive Programming With Java 8

You're reading from   Learning Reactive Programming With Java 8 Learn how to use RxJava and its reactive Observables to build fast, concurrent, and powerful applications through detailed examples

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher Packt
ISBN-13 9781785288722
Length 182 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Nickolay Tzvetinov Nickolay Tzvetinov
Author Profile Icon Nickolay Tzvetinov
Nickolay Tzvetinov
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. An Introduction to Reactive Programming FREE CHAPTER 2. Using the Functional Constructions of Java 8 3. Creating and Connecting Observables, Observers, and Subjects 4. Transforming, Filtering, and Accumulating Your Data 5. Combinators, Conditionals, and Error Handling 6. Using Concurrency and Parallelism with Schedulers 7. Testing Your RxJava Application 8. Resource Management and Extending RxJava Index

Resource management


If we look back at the HTTP request method that we used in Chapter 6, Using Concurrency and Parallelism with Schedulers and Chapter 5, Combinators, Conditionals, and Error Handling, it has this signature: Observable<Map> requestJson(HttpAsyncClient client, String url).

Instead of just calling a method that makes a request to a URL and returns the response as JSON, we create a HttpAsyncClient instance, have to start the it and pass it to the requestJson() method. But there is more: we need to close the client after we read the result, and because the observable is asynchronous, we need to wait for its OnCompleted notification and then to do the closing. This is very complex and should be changed. The Observable, which read from files, need to create streams/readers/channels and close them when all the subscribers are unsubscribed. The Observable, emitting data from a database should set up and then close all the connections, statements, and result sets that are used...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime