Full Download Learning Reactive Programming with Java 8 1st Edition Nickolay Tsvetinov PDF DOCX
Full Download Learning Reactive Programming with Java 8 1st Edition Nickolay Tsvetinov PDF DOCX
com
https://ebookname.com/product/learning-reactive-programming-
with-java-8-1st-edition-nickolay-tsvetinov/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/pro-java-8-programming-3rd-edition-
terrill-brett-spell/
ebookname.com
https://ebookname.com/product/functional-reactive-programming-1st-
edition-stephen-blackheath/
ebookname.com
https://ebookname.com/product/practical-database-programming-with-
java-1st-edition-ying-bai/
ebookname.com
https://ebookname.com/product/themes-in-speculative-psychology-
nehemiah-jordan/
ebookname.com
Prelude to the Monsoon Assignment in Sumatra G. F. Jacobs
https://ebookname.com/product/prelude-to-the-monsoon-assignment-in-
sumatra-g-f-jacobs/
ebookname.com
https://ebookname.com/product/c21-communicating-in-the-21st-
century-3rd-edition-baden-eunson/
ebookname.com
https://ebookname.com/product/student-centered-coaching-a-guide-
for-k-8-coaches-and-principals-1st-edition-diane-sweeney/
ebookname.com
https://ebookname.com/product/the-law-of-obligations-connections-and-
boundaries-2nd-edition-andrew-robertson/
ebookname.com
https://ebookname.com/product/deviant-burial-in-the-archaeological-
record-1st-edition-eileen-m-murphy/
ebookname.com
Thermoelectric Skutterudites 1st Edition Ctirad Uher
https://ebookname.com/product/thermoelectric-skutterudites-1st-
edition-ctirad-uher/
ebookname.com
Table of Contents
Learning Reactive Programming with Java 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. An Introduction to Reactive Programming
What is reactive programming?
Why should we be reactive?
Introducing RxJava
Downloading and setting up RxJava
Comparing the iterator pattern and the RxJava Observable
Implementing the reactive sum
Summary
2. Using the Functional Constructions of Java 8
Lambdas in Java 8
Introducing the new syntax and semantics
Functional interfaces in Java 8 and RxJava
Implementing the reactive sum example with lambdas
Pure functions and higher order functions
Pure functions
Higher order functions
RxJava and functional programming
Summary
3. Creating and Connecting Observables, Observers, and Subjects
The Observable.from method
The Observable.just method
Other Observable factory methods
The Observable.create method
Subscribing and unsubscribing
Hot and cold Observable instances
The ConnectableObservable class
The Subject instances
Summary
4. Transforming, Filtering, and Accumulating Your Data
Observable transformations
Transformations with the various flatMap operators
Grouping items
Additional useful transformation operators
Filtering data
Accumulating data
Summary
5. Combinators, Conditionals, and Error Handling
Combining the Observable instances
The zip operator
The combineLatest operator
The merge operator
The concat operator
The conditional operators
The amb operator
The takeUntil(), takeWhile(), skipUntil(), and skipWhile()
conditional operators
The defaultIfEmpty( ) operator
Handling errors
The return and resume operators
The retrying technique
An HTTP client example
Summary
6. Using Concurrency and Parallelism with Schedulers
RxJava's schedulers
Debugging Observables and their schedulers
The interval Observable and its default scheduler
Types of schedulers
The Schedulers.immediate scheduler
The Schedulers.trampoline scheduler
The Schedulers.newThread scheduler
The Schedulers.computation scheduler
The Schedulers.io scheduler
The Schedulers.from(Executor) method
Combining Observables and schedulers
The Observable<T> subscribeOn(Scheduler) method
The Observable<T> observeOn(Scheduler) operator
Parallelism
Buffering, throttling, and debouncing
Throttling
Debouncing
The buffer and window operators
The backpressure operators
Summary
7. Testing Your RxJava Application
Testing using simple subscription
The BlockingObservable class
The aggregate operators and the BlockingObservable class
Testing with the aggregate operators and the BlockingObservable
class
Using the TestSubscriber class for in-depth testing
Testing asynchronous Observable instances with the help of the
TestScheduler class
Summary
8. Resource Management and Extending RxJava
Resource management
Introducing the Observable.using method
Caching data with Observable.cache
Creating custom operators with lift
Composing multiple operators with the Observable.compose
operator
Summary
Index
Learning Reactive
Programming with Java 8
Learning Reactive
Programming with Java 8
Copyright © 2015 Packt Publishing
Every effort has been made in the preparation of this book to ensure
the accuracy of the information presented. However, the information
contained in this book is sold without warranty, either express or
implied. Neither the author, nor Packt Publishing, and its dealers and
distributors will be held liable for any damages caused or alleged to
be caused directly or indirectly by this book.
Livery Place
35 Livery Street
ISBN 978-1-78528-872-2
www.packtpub.com
Credits
Author
Nickolay Tsvetinov
Reviewers
Samuel Gruetter
Dávid Karnok
Timo Tuominen
Shixiong Zhu
Commissioning Editor
Veena Pagare
Acquisition Editor
Larrisa Pinto
Adrian Raposo
Technical Editor
Abhishek R. Kotian
Copy Editors
Brandt D'mello
Neha Vyas
Project Coordinator
Sanchita Mandal
Proofreader
Safis Editing
Indexer
Mariammal Chettiyar
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
About the Author
Nickolay Tsvetinov is a professional all-round web developer at
TransportAPI—Britain's first comprehensive open platform for
transport solutions. During his career as a software developer, he
experienced both good and bad and played with most of the popular
programming languages—from C and Java to Ruby and JavaScript.
For the last 3-4 years, he's been creating and maintaining single-
page applications (SPA) and the backend API architectures that
serve them. He is a fan of open source software, Rails, Vim, Sinatra,
Ember.js, Node.js, and Nintendo. He was an unsuccessful musician
and poet, but he is a successful husband and father. His area of
interest and expertise includes the declarative/functional and
reactive programming that resulted in the creation of ProAct.js
(http://proactjs.com), which is a library that augments the JavaScript
language and turns it into a reactive language.
He has been working with Java and related core technologies since
2005 to bring Java's benefits to manufacturing and logistic
companies.
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to
the eBook version at www.PacktPub.com and as a print book
customer, you are entitled to a discount on the eBook copy. Get in
touch with us at <service@packtpub.com> for more details.
https://www2.packtpub.com/books/subscription/packtlib
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can
use this to access PacktLib today and view 9 entirely free books.
Simply use your login credentials for immediate access.
Preface
Reactive programming has been around for decades. There has
been a few implementations of reactive programming from the time
Smalltalk was a young language. However, it has only become
popular recently and it is now becoming a trend. Why now you ask?
Because it is good for writing fast, real-time applications and current
technologies and the Web demand this.
I got involved in it back in 2008, when the team I was part of was
developing a multimedia book creator called Sophie 2. It had to be
fast and responsive so we created a framework called Prolib, which
provided objects with properties which could depend on each other
(in other words, we implemented bindings for Swing and much more
—transformations, filtering, and so on). It felt natural to wire the
model data to the GUI like this.
Of course, this was far away from the functional-like approach that
comes with RX. In 2010, Microsoft released RX and, after that,
Netflix ported it to Java—RxJava. However, Netflix released RxJava
to the open source community and the project became a huge
success. Many other languages have their port of RX and many
alternatives to it. Now, you can code using reactive programming on
your Java backend and wire it to your RxJava's frontend.
Observable
.just('R', 'x', 'J', 'a', 'v', 'a')
.subscribe(
System.out::print,
System.err::println,
System.out::println
);
New terms and important words are shown in bold. Words that you
see on the screen, for example, in menus or dialog boxes, appear in
the text like this: "Interfaces of this type are called functional
interfaces."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what
you think about this book—what you liked or disliked. Reader
feedback is important for us as it helps us develop titles that you will
really get the most out of.
If there is a topic that you have expertise in and you are interested in
either writing or contributing to a book, see our author guide at
www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a
number of things to help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our
content, mistakes do happen. If you find a mistake in one of our
books—maybe a mistake in the text or the code—we would be
grateful if you could report this to us. By doing so, you can save
other readers from frustration and help us improve subsequent
versions of this book. If you find any errata, please report them by
visiting http://www.packtpub.com/submit-errata, selecting your book,
clicking on the Errata Submission Form link, and entering the
details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded to our website or
added to any list of existing errata under the Errata section of that
title.
Piracy
Random documents with unrelated
content Scribd suggests to you:
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com