0% found this document useful (0 votes)
29 views51 pages

Slides ReactiveProg CambierRomain

Reactive Programming with RxJava is a library for composing asynchronous and event-based programs using observable sequences. RxJava allows processing streams of data asynchronously without blocking or callbacks. It uses Observables to represent asynchronous data streams and allows these streams to be transformed in a declarative way using operators. Key features include being responsive, resilient, and elastic by reacting to user input, errors, and load changes through processing message and event streams.

Uploaded by

kanchan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views51 pages

Slides ReactiveProg CambierRomain

Reactive Programming with RxJava is a library for composing asynchronous and event-based programs using observable sequences. RxJava allows processing streams of data asynchronously without blocking or callbacks. It uses Observables to represent asynchronous data streams and allows these streams to be transformed in a declarative way using operators. Key features include being responsive, resilient, and elastic by reacting to user input, errors, and load changes through processing message and event streams.

Uploaded by

kanchan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Reactive Programming with RxJava

Shareif.com
About me

Romain Cambier
@r_cambier github.com/cambierr
romain@shareif.com

CS Engineer from Mons (172), BE


Founder & Owner of Shareif.com
Founder of TTN Belgium
Intro
Today's apps: Facebook

get profile

get friends

.
get news

get news
www.facebook.com

get chats
get msgs Facebook

...
messenger
get msgs
get ads

Facebook ads
Today's apps: General

Application/Website

File Storage API Database ...


Today's apps: General

Your app

time spent waiting

Your db
Today's apps: My Super E-Shop

10 k 100 k, 10 / user 10 k, 10 / order


Today's apps: My Super E-Shop

How much money have the first 1000


users spent in my shop (per user) ?
Today's apps: My Super E-Shop
Today's apps: My Super E-Shop
RxJava
RxJava is:

Reactive Extension for the JVM:

A library for composing asynchronous and event-based


programs using observable sequences
Reminder: Observable DP
Reminder: Observable DP
Observable Observer

registerObserver(me)
This means : Derpina, keep me in touch !

Something happens to Derpina

notify(data)
This means : Derp, I'm pregnant
Derp just died..
Reactive means :

RESPONSIVE
(react to users input)

RESILIENT
(react to errors and failures)

ELASTIC
(react to load)

MESSAGE-DRIVEN
(react to events and message)
RX Observable
=
Chained Observables
RX Observable
Observable Observable Observable

observe(me)
observe(me)

...
observe(me)

onNext(data)

onNext(data)
onNext(data)
Steam? Everything is aIf you
stream!
try hard enough

New student create student

Assign a class Give him housing

Give him
Create a password
login & password
Steam? Everything is aIf you
stream!
try hard enough

So this means:

When you have a new student, create it in your db.


Then, give gim a student housing.
After that, assign him a class.
You should then create a password.
And finally, give him its login & pass.
Just remember this:

Reactive programming is about


dealing with event stream
RX Observable DP
Observable Subscriber

subscribe(me)

onStart()

onNext(data)
onCompleted()

onError(exception)
RxJava Operators
Empty
Just
From
Error
Range
Interval
Subscriber
Map
FlatMap
ToList
Filter
GroupBy
Take / TakeLast
Skip / SkipLast
Count
Distinct
IgnoreElements
First / Last / Single
Create
Multi-threading made easy
(No, really)
Playing with Threads

Schedulers :

IO: For all I/O operations


Computation: For computational work

NewThread: A new thread for each job

Trampoline: Wait for your thread to be available

Immediate: Do it, now.


SubscribeOn
ObserveOn
Playing with threads

This is single-thread code :

This takes 100,000 ms to run


Playing with threads

This is multi-thread code :

This takes 1,000 ms to run


DIY time!
RX is also:

RxJava RxJs Rx.NET UniRx


RxScala RxClojure RxCpp Rx.rb
RxPY RxGroovy RxJRuby RxKotlin
RxSwift RxPHP RxQuasar RxRust
RxRoboVM RxGo

RxNetty RxAndroid RxCocoa RxApacheHttp


RxJavaFileUtils RxJavaFX RxSwing
Meta

Images are from : http://reactivex.io

RX javadoc : http://goo.gl/Cu4zcD

Database used : http://couchbase.com

Docker : http://docker.com

DIY sources : https://goo.gl/9bnhNy


Shareif.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy