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 2. Using the Functional Constructions of Java 8 FREE CHAPTER 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

Pure functions and higher order functions

You don't have to remember most of the terms introduced in this chapter; the important thing is to understand how they help us write simplistic but powerful programs.

RxJava's approach has many functional ideas incorporated, so it is important for us to learn how to think in more functional ways in order to write better reactive applications.

Pure functions

A pure function is a function whose return value is only determined by its input, without observable side effects. If we call it with the same parameters n times, we are going to get the same result every single time. For example:

Predicate<Integer> even = (number) -> number % 2 == 0;
int i = 50;
while((i--) > 0) {
  System.out.println("Is five even? - " + even.test(5));
}

Each time, the even function returns False because it depends only on its input, which is the same each time and is not even.

This property of pure functions is called idempotence. Idempotent functions...

You have been reading a chapter from
Learning Reactive Programming With Java 8
Published in: Jun 2015
Publisher: Packt
ISBN-13: 9781785288722
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