Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
REACTIVE JAVA
REACTIVE

“readily responsive to a stimulus”
Merriam-Webster dictionary
RX JAVA BY NETFLIX
• A library for composing asynchronous and
event-based programs using observable
sequences for the Java...
OBSERVER ->

OBSERVABLE ->
SUBCRIPTIONS AND EVENTS

subscribe

onNext*

onCompleted | onError
t
SERVICE RETURNING OBSERVABLE
public interface ShrödingersCat {
Observable<Boolean> alive();
}
cat
.alive()
.subscribe(stat...
SERVICE RETURNING OBSERVABLE
public interface ShrödingersCat {
Observable<Boolean> alive();
}
cat
.alive()
.throttleWithTi...
OBSERVER
public interface Observer<T> {
void onCompleted();
void onError(Throwable e);
void onNext(T args);
}
SUBSCRIPTION
public interface Subscription {
void unsubscribe();
}
CREATING OBSERVABLES
Observable<Boolean> watchTheCat =
Observable.create(observer -> {
observer.onNext(cat.isAlive());
obs...
CREATING OBSERVABLES
Observable.create(observer -> {
Future<?> future = executorService.submit(() -> {
observer.onNext(cat...
MARBLE DIAGRAM
MERGE(OBSERVABLE...)
CONCAT(OBSERVABLE...)
DEBOUNCE(LONG TIEMOUT, TIMEUNIT TU)
ZIP(OBSERVABLE, OBSERVABLE, FUNC2)
HOW WE USE IT – DATA FILE DISCOVERY
Amazon S3

cache

cache

Disk

cache

mergeDelayError

Memory
Upcoming SlideShare
Loading in …5
×

Introduction to Reactive Java

Introduction to Reactive Java library created by Netflix

  • Be the first to comment

Introduction to Reactive Java

  1. 1. REACTIVE JAVA
  2. 2. REACTIVE “readily responsive to a stimulus” Merriam-Webster dictionary
  3. 3. RX JAVA BY NETFLIX • A library for composing asynchronous and event-based programs using observable sequences for the Java VM • Implementation of Rx Observables from Microsoft • Targets the JVM not a language. Currently supports Java, Groovy, Clojure, and Scala • https://github.com/Netflix/RxJava • Apache License, Version 2.0
  4. 4. OBSERVER -> OBSERVABLE ->
  5. 5. SUBCRIPTIONS AND EVENTS subscribe onNext* onCompleted | onError t
  6. 6. SERVICE RETURNING OBSERVABLE public interface ShrödingersCat { Observable<Boolean> alive(); } cat .alive() .subscribe(status -> System.out.println(status));
  7. 7. SERVICE RETURNING OBSERVABLE public interface ShrödingersCat { Observable<Boolean> alive(); } cat .alive() .throttleWithTimeout(250, TimeUnit.MILLISECONDS) .distinctUntilChanged() .filter(isAlive -> isAlive) .map(Boolean::toString) .subscribe(status -> display.display(status));
  8. 8. OBSERVER public interface Observer<T> { void onCompleted(); void onError(Throwable e); void onNext(T args); }
  9. 9. SUBSCRIPTION public interface Subscription { void unsubscribe(); }
  10. 10. CREATING OBSERVABLES Observable<Boolean> watchTheCat = Observable.create(observer -> { observer.onNext(cat.isAlive()); observer.onCompleted(); return Subscriptions.empty(); }); • Executes all code when subscribed • Not asynchronous, not really a stream
  11. 11. CREATING OBSERVABLES Observable.create(observer -> { Future<?> future = executorService.submit(() -> { observer.onNext(cat.isAlive()); observer.onCompleted(); }); return Subscriptions.from(future); }); • • • • Executes code in separate thread (from thread pool executorService) Stream of events is delivered by the executor thread Thread calling onNext() runs all the operations defined on observable Future is cancelled if client unsubscribes
  12. 12. MARBLE DIAGRAM
  13. 13. MERGE(OBSERVABLE...)
  14. 14. CONCAT(OBSERVABLE...)
  15. 15. DEBOUNCE(LONG TIEMOUT, TIMEUNIT TU)
  16. 16. ZIP(OBSERVABLE, OBSERVABLE, FUNC2)
  17. 17. HOW WE USE IT – DATA FILE DISCOVERY Amazon S3 cache cache Disk cache mergeDelayError Memory

    Be the first to comment

    Login to see the comments

  • tantrieuf31

    Jan. 24, 2014
  • thinkpanda

    Aug. 6, 2014
  • phongtn

    Oct. 31, 2014
  • BenjaminBRABANT

    Nov. 12, 2014
  • RiccardoTommasini

    Jan. 4, 2015
  • ivansanchez1988

    Jan. 8, 2015
  • bunkertor

    Feb. 5, 2015
  • azm102

    Jun. 5, 2015
  • mariuszostapowicz

    Oct. 12, 2015
  • YuichiHamasaki

    Oct. 23, 2015
  • shan_mylearning

    Jan. 1, 2016
  • sharmisthamona

    Sep. 6, 2016
  • Jasonmao5

    May. 24, 2018
  • tvmani

    Nov. 18, 2018
  • VinhCuongTran1

    Jun. 20, 2020

Introduction to Reactive Java library created by Netflix

Views

Total views

13,969

On Slideshare

0

From embeds

0

Number of embeds

7

Actions

Downloads

280

Shares

0

Comments

0

Likes

15

×