SlideShare a Scribd company logo
Reactive in Android & beyond Rx
Fabio Tiriticco / @ticofab
DAUG Meetup 23 August 2016
A little info about myself
Android	Engineer	
Backend	Architect
The Reactive Amsterdam meetup
Reactive Amsterdam
• cross-technology	
• cross-domain
“Reactive” in the vocabulary
Reactive (adjective):
Tending to act in response to an agent or influence
Reactive Confusion
Functional	Reactive	Programming
Reactive	in	the	context	of	the	“Reactive	Manifesto”
OR
Reactive Programming
Why Functional?
More	supportive	of	reasoning	about	problems	in	concurrent	and	
parallelised	applications.
• encourages	use	of	pure	functions	-	minimise	side	effects	
• encourages	immutability	-	state	doesn’t	get	passed	around	
• higher-order	functions	-	reusability	and	composability
Hello, RxJava!
Mobile	engineering	is	hard	and	there	are	high	expectations.
RxJava	is	cool	because
• it	makes	it	super	easy	to	switch	between	threads	
• lets	us	deal	with	data	as	a	stream	
• brings	us	some	degree	of	functional	programming
Hello, RxJava!
RxJava
RxJs
RxClojure
RxSwift
…
• Asynchronous	programming	
• Observable	streams
Open	source	libraries	for
RxJava goes hand in hand with Java8’s Lambdas
new Func1<String, Integer>() {
@Override
public Integer call(String s) {
return s.length();
}
}
(String s) -> {
return s.length();
}
s -> s.length();
Retrolamba	plugin	for	
Android	<	N
RxJava: dealing with a stream of items
class Cat {
...
public String getName()
public Color getColor()
public Picture fetchPicture()
...
}
RxJava: dealing with a stream of items
Observable.from(myCats);
cat -> Timber.d(cat.getName())
List<Cat> myCats;
Observable obs =
obs.subscribe( );
Observable.from(myCats)
.subscribe(cat -> Timber.d(cat.getName()));
RxJava: work on the stream
Observable.from(myCats)
.subscribe(color -> Timber.d(color));
map: function that takes T => outputs R
.map( )cat -> cat.getColor()
RxJava: operators to manipulate the stream
Observable.from(myCats)
.distinct()
.delay(2, TimeUnit.SECONDS)
.filter(cat -> cat.getColor().isWhite())
.map(cat -> cat.getName())
.subscribe(name ->
Timber.d(“a unique, delayed white cat called ” + name));
Observable.from(myCats)
.subscribe(
cat -> Timber.d(cat.getName()),
error -> error.printStackTrace(),
() -> Timber.d(“no more cats”)
);
RxJava: subscriber interface
Observable.from(myCats)
.subscribe(
onNext<T>, // next item T
onError, // throwable
onComplete // void
);
Observable.from(myCats)
.subscribe(cat -> Timber.d(“cat”));
RxJava: unsubscribe
Subscription subs =
subs.unsubscribe();
RxJava: threading
Observable.from(myCats)
.map(cat -> cat.fetchPicture())
.map(picture -> Filter.applyFilter(picture))
.subscribe(
filteredPicture -> display(filteredPicture)
);
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
RxJava: other ways of creating Observables
// emits on single item and completes
Observable.just
// emits one item after a certain delay
Observable.timer
// emits a series of integers at regular pace
Observable.interval
.. plus many others, and you can create your own
— BUT TRY NOT TO -
RxJava: a few disadvantages
• debugging	is	more	difficult	
• methods	with	side	effects	
• powerful	abstraction	-	lot	of	stuff	under	the	hood
RxJava: demo with Retrofit & Meetup Streams
http://stream.meetup.com/2/rsvp
Meetup Streaming API
RxJava: demo with Meetup Streams
RxJava: demo with Retrofit & Meetup Streams
interface MeetupAPI {
@GET("http://stream.meetup.com/2/rsvp")
@Streaming
Observable<ResponseBody> meetupStream();
}
RxJava: demo with RSVP Meetup Streams
meetupAPI.meetupStream()
...
.flatMap(responseBody -> events(responseBody.source()))
.map(string -> gson.fromJson(string, RSVP.class))
...
.subscribe(rsvp -> ...);
map: T => R
flatMap: T => Observable<R>
RxJava: demo with Meetup Streams
RxJava: demo with Meetup Streams
https://github.com/ticofab/android-meetup-streams
2006 2016
Servers ~10 The	sky	is	the	limit.
Response	time seconds milliseconds
Offline	maintenance hours what?
Data	amount Gigabytes Petabytes
Machines Single	core,	little	distribution
Must	work	across	async	
boundaries	(location,	threads)
Kind	of	data Request	-	response Streams	(endless)
Reactive in the sense of the Reactive Manifesto
Evolution of internet usage
The Reactive traits
A	reactive	computer	system	must Trait
React	to	its	users Responsive
React	to	failure	and	stay	available Resilient
React	to	varying	load	conditions Elastic
Its	components	must	react	to	inputs Message-driven
Reactive traits: Responsive
• A	human	who	visits	a	website	
• A	client	which	makes	a	request	to	a	server	
• A	consumer	which	contacts	a	provider	
• .	.	.	
A	Reactive	system	responds	to	inputs	and	usage	from	its	user.
Reactive traits: Elastic
• Scale	OUT	and	IN:	use	just	the	right	amount	
• Elasticity	relies	on	distribution	
• Ensure	replication	in	case	of	failure
Scale	on	demand	to	react	to	varying	load
Reactive traits: Resilient
It	doesn't	matter	how	great	your	application	is	if	it	doesn't	work.
FAULT	TOLERANCE RESILIENCEVS
Reactive traits: Message Driven
Reactive	systems	design	concentrates	on	Messages.
Asynchronous	messaging	enables:
• Separation	between	components	
• Error	containment	-	avoid	chain	failures	
• Domain	mapping	closer	to	reality
The Reactive Manifesto
Reactive Patterns
Design	patterns	to	achieve	Reactive	principles.	
Toolkits	exist	to	implement	these	patterns.
Reactive Pattern: Simple Component Pattern
“One	component	should	do	only	one	thing	but	do	it	in	full.	The	aim	is	to	
maximise	cohesion	and	minimise	coupling	between	components.”
Reactive Pattern: Simple Component Pattern
Actor	1
	Actor	3
Actor	2
• contains	state	
• has	a	mailbox	to	receive	
and	send	messages	
• contains	behaviour	logic	
• has	a	supervisor
Actor	model Supervisor
Example: Synchronous DB access
Activity DB	service DB
List<Cat> cats = new ArrayList<Cat>();
try {
cats = dbService.getAllCats();
} catch (ExampleException e) {
// TODO
}
Example: DB access with callback
dbService.getAllCats(new OnCompleted() {
@Override
public void onDataRetrieved(List<Cat> cats) {
// TODO
}
});
Activity DB	service DB
Example: Async Messaging with Actors
Activity	
actor
DB	Actor DB
Example: Async Messaging with Actors - messages
// message to ask for cats
public class GetCats {
}
// message to send results back
public class Results {
ArrayList<Cat> mCats;
public Results(ArrayList<Cat> cats) {
mCats = cats;
}
}
Example: Async Messaging with Actors - behaviour
// db actor pseudocode
@Override
public void onReceive(Message message) {
}
if (message is GetCats) {
}
// retrieve cats from database
c = contentResolver.query(...)
...
// send cats to the Activity
Results result = new Results(cats);
activityAddress.tell(result)
Reactive Patterns: Let it crash!
"Prefer	a	full	component	restart	to	complex	internal	failure	handling".
• failure	conditions	WILL	occur	
• they	might	be	rare	and	hard	to	reproduce	
• it	is	much	better	to	start	clean	than	to	try	to	recover	
• …which	might	be	expensive	and	difficult!
Reactive Patterns: Let it crash!
Actor	supervision	example
Actor	1
	Actor	2
Supervisor
WhateverException!
X
Fix	or	
Restart
Reactive Patterns: Let it crash!
• the	machine	only	
accepts	exact	change
Reactive Patterns: Let it crash!
Scenario	1:	
The	user	inserts	wrong	
amount	of	coins
X
Error
Reactive Patterns: Let it crash!
Scenario	2:	
The	machine	is	out	of	
coffee	beans
Failure
(	!=	error)
Reactive Patterns: Let it crash!
Recap
• Tried	to	clarify	the	Reactive	Confusion	
• Examples	of	FRP	in	Android	
• Reactive	principles	from	the	Reactive	Manifesto	
• A	couple	of	Design	Patterns	to	achieve	them	
• (with	a	glimpse	of	pseudo	implementation)
Reactive Amsterdam
Thanks!
@ticofab
All pictures belong
to their respective authors
AMSTERDAM 11-12 MAY 2016
Resources
https://github.com/ReactiveX/RxJava/wiki RxJava	documentation	&	wiki
http://rxmarbles.com RxJava	operators	explained	visually
http://www.reactivemanifesto.org The	reactive	manifesto
https://www.youtube.com/watch?v=fNEZtx1VVAk	
https://www.youtube.com/watch?v=ryIAibBibQI	
https://www.youtube.com/watch?v=JvbUF33sKf8
The	Reactive	Revealed	series:	awesome	webinars	by	the	
creators	of	the	Reactive	Manifesto.
https://www.manning.com/books/reactive-design-patterns	
https://www.youtube.com/watch?v=nSfXcSWq0ug
Reactive	design	patterns,	book	and	webinar.

More Related Content

What's hot

OSDC 2014: Jordan Sissel - Find Happiness in your Logs
 OSDC 2014: Jordan Sissel - Find Happiness in your Logs OSDC 2014: Jordan Sissel - Find Happiness in your Logs
OSDC 2014: Jordan Sissel - Find Happiness in your Logs
NETWAYS
 
Apache Flink 101 - the rise of stream processing and beyond
Apache Flink 101 - the rise of stream processing and beyondApache Flink 101 - the rise of stream processing and beyond
Apache Flink 101 - the rise of stream processing and beyond
Bowen Li
 
A Tool For Big Data Analysis using Apache Spark
A Tool For Big Data Analysis using Apache SparkA Tool For Big Data Analysis using Apache Spark
A Tool For Big Data Analysis using Apache Spark
datamantra
 
Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache Flink
Tugdual Grall
 
What's new in confluent platform 5.4 online talk
What's new in confluent platform 5.4 online talkWhat's new in confluent platform 5.4 online talk
What's new in confluent platform 5.4 online talk
confluent
 
Reactive Programming In Java Using: Project Reactor
Reactive Programming In Java Using: Project ReactorReactive Programming In Java Using: Project Reactor
Reactive Programming In Java Using: Project Reactor
Knoldus Inc.
 
End to-end large messages processing with Kafka Streams & Kafka Connect
End to-end large messages processing with Kafka Streams & Kafka ConnectEnd to-end large messages processing with Kafka Streams & Kafka Connect
End to-end large messages processing with Kafka Streams & Kafka Connect
confluent
 
When Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu MaWhen Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu Ma
Databricks
 
Apache Flink(tm) - A Next-Generation Stream Processor
Apache Flink(tm) - A Next-Generation Stream ProcessorApache Flink(tm) - A Next-Generation Stream Processor
Apache Flink(tm) - A Next-Generation Stream Processor
Aljoscha Krettek
 
Rx Reactive programming
Rx Reactive programmingRx Reactive programming
Rx Reactive programming
lucas34990
 
Parallel Development in VS10
Parallel Development in VS10Parallel Development in VS10
Parallel Development in VS10
Valdis Iljuconoks
 
Improving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time SparkImproving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time Spark
datamantra
 
Whats new in_mlflow
Whats new in_mlflowWhats new in_mlflow
Whats new in_mlflow
Databricks
 
SAIS2018 - Fact Store At Netflix Scale
SAIS2018 - Fact Store At Netflix ScaleSAIS2018 - Fact Store At Netflix Scale
SAIS2018 - Fact Store At Netflix Scale
Nitin S
 
Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
 Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa... Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
Databricks
 
Understanding time in structured streaming
Understanding time in structured streamingUnderstanding time in structured streaming
Understanding time in structured streaming
datamantra
 
Using Kafka to integrate DWH and Cloud Based big data systems
Using Kafka to integrate DWH and Cloud Based big data systemsUsing Kafka to integrate DWH and Cloud Based big data systems
Using Kafka to integrate DWH and Cloud Based big data systems
confluent
 
MLOps - Build pipelines with Tensor Flow Extended & Kubeflow
MLOps - Build pipelines with Tensor Flow Extended & KubeflowMLOps - Build pipelines with Tensor Flow Extended & Kubeflow
MLOps - Build pipelines with Tensor Flow Extended & Kubeflow
Jan Kirenz
 
Apache Flink and what it is used for
Apache Flink and what it is used forApache Flink and what it is used for
Apache Flink and what it is used for
Aljoscha Krettek
 
The Past, Present, and Future of Apache Flink®
The Past, Present, and Future of Apache Flink®The Past, Present, and Future of Apache Flink®
The Past, Present, and Future of Apache Flink®
Aljoscha Krettek
 

What's hot (20)

OSDC 2014: Jordan Sissel - Find Happiness in your Logs
 OSDC 2014: Jordan Sissel - Find Happiness in your Logs OSDC 2014: Jordan Sissel - Find Happiness in your Logs
OSDC 2014: Jordan Sissel - Find Happiness in your Logs
 
Apache Flink 101 - the rise of stream processing and beyond
Apache Flink 101 - the rise of stream processing and beyondApache Flink 101 - the rise of stream processing and beyond
Apache Flink 101 - the rise of stream processing and beyond
 
A Tool For Big Data Analysis using Apache Spark
A Tool For Big Data Analysis using Apache SparkA Tool For Big Data Analysis using Apache Spark
A Tool For Big Data Analysis using Apache Spark
 
Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache Flink
 
What's new in confluent platform 5.4 online talk
What's new in confluent platform 5.4 online talkWhat's new in confluent platform 5.4 online talk
What's new in confluent platform 5.4 online talk
 
Reactive Programming In Java Using: Project Reactor
Reactive Programming In Java Using: Project ReactorReactive Programming In Java Using: Project Reactor
Reactive Programming In Java Using: Project Reactor
 
End to-end large messages processing with Kafka Streams & Kafka Connect
End to-end large messages processing with Kafka Streams & Kafka ConnectEnd to-end large messages processing with Kafka Streams & Kafka Connect
End to-end large messages processing with Kafka Streams & Kafka Connect
 
When Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu MaWhen Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu Ma
 
Apache Flink(tm) - A Next-Generation Stream Processor
Apache Flink(tm) - A Next-Generation Stream ProcessorApache Flink(tm) - A Next-Generation Stream Processor
Apache Flink(tm) - A Next-Generation Stream Processor
 
Rx Reactive programming
Rx Reactive programmingRx Reactive programming
Rx Reactive programming
 
Parallel Development in VS10
Parallel Development in VS10Parallel Development in VS10
Parallel Development in VS10
 
Improving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time SparkImproving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time Spark
 
Whats new in_mlflow
Whats new in_mlflowWhats new in_mlflow
Whats new in_mlflow
 
SAIS2018 - Fact Store At Netflix Scale
SAIS2018 - Fact Store At Netflix ScaleSAIS2018 - Fact Store At Netflix Scale
SAIS2018 - Fact Store At Netflix Scale
 
Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
 Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa... Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
 
Understanding time in structured streaming
Understanding time in structured streamingUnderstanding time in structured streaming
Understanding time in structured streaming
 
Using Kafka to integrate DWH and Cloud Based big data systems
Using Kafka to integrate DWH and Cloud Based big data systemsUsing Kafka to integrate DWH and Cloud Based big data systems
Using Kafka to integrate DWH and Cloud Based big data systems
 
MLOps - Build pipelines with Tensor Flow Extended & Kubeflow
MLOps - Build pipelines with Tensor Flow Extended & KubeflowMLOps - Build pipelines with Tensor Flow Extended & Kubeflow
MLOps - Build pipelines with Tensor Flow Extended & Kubeflow
 
Apache Flink and what it is used for
Apache Flink and what it is used forApache Flink and what it is used for
Apache Flink and what it is used for
 
The Past, Present, and Future of Apache Flink®
The Past, Present, and Future of Apache Flink®The Past, Present, and Future of Apache Flink®
The Past, Present, and Future of Apache Flink®
 

Viewers also liked

WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
Fabio Tiriticco
 
Sword fighting with Dagger GDG-NYC Jan 2016
 Sword fighting with Dagger GDG-NYC Jan 2016 Sword fighting with Dagger GDG-NYC Jan 2016
Sword fighting with Dagger GDG-NYC Jan 2016
Mike Nakhimovich
 
Intro to Functional Programming with RxJava
Intro to Functional Programming with RxJavaIntro to Functional Programming with RxJava
Intro to Functional Programming with RxJava
Mike Nakhimovich
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
allegro.tech
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
Supercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactSupercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-react
John McClean
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
José Paumard
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
Kasun Indrasiri
 
Introduction to Reactive Java
Introduction to Reactive JavaIntroduction to Reactive Java
Introduction to Reactive Java
Tomasz Kowalczewski
 

Viewers also liked (10)

WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Sword fighting with Dagger GDG-NYC Jan 2016
 Sword fighting with Dagger GDG-NYC Jan 2016 Sword fighting with Dagger GDG-NYC Jan 2016
Sword fighting with Dagger GDG-NYC Jan 2016
 
rx-java-presentation
rx-java-presentationrx-java-presentation
rx-java-presentation
 
Intro to Functional Programming with RxJava
Intro to Functional Programming with RxJavaIntro to Functional Programming with RxJava
Intro to Functional Programming with RxJava
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Supercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactSupercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-react
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
Introduction to Reactive Java
Introduction to Reactive JavaIntroduction to Reactive Java
Introduction to Reactive Java
 

Similar to Reactive in Android and Beyond Rx

Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
Codemotion
 
Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyond
Fabio Tiriticco
 
RxJS vs RxJava: Intro
RxJS vs RxJava: IntroRxJS vs RxJava: Intro
RxJS vs RxJava: Intro
Martin Toshev
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018
Trayan Iliev
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
Trayan Iliev
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionals
Trayan Iliev
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
Grant Steinfeld
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
Ali Muzaffar
 
RxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptRxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScript
Viliam Elischer
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
VMware Tanzu
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in Depth
Trayan Iliev
 
Reactive Programming with RxJS
Reactive Programming with RxJSReactive Programming with RxJS
Reactive Programming with RxJS
Danca Prima
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive Programming
Supun Dissanayake
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Trayan Iliev
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
Naresh Chintalcheru
 
IPT Reactive Java IoT Demo - BGOUG 2018
IPT Reactive Java IoT Demo - BGOUG 2018IPT Reactive Java IoT Demo - BGOUG 2018
IPT Reactive Java IoT Demo - BGOUG 2018
Trayan Iliev
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
Troy Miles
 
RDF Stream Processing: Let's React
RDF Stream Processing: Let's ReactRDF Stream Processing: Let's React
RDF Stream Processing: Let's React
Jean-Paul Calbimonte
 
Reactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiReactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary Grygleski
PolyglotMeetups
 
Reactive mesh
Reactive meshReactive mesh
Reactive mesh
Kalin Maldzhanski
 

Similar to Reactive in Android and Beyond Rx (20)

Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
 
Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyond
 
RxJS vs RxJava: Intro
RxJS vs RxJava: IntroRxJS vs RxJava: Intro
RxJS vs RxJava: Intro
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionals
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
RxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptRxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScript
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in Depth
 
Reactive Programming with RxJS
Reactive Programming with RxJSReactive Programming with RxJS
Reactive Programming with RxJS
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive Programming
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
 
IPT Reactive Java IoT Demo - BGOUG 2018
IPT Reactive Java IoT Demo - BGOUG 2018IPT Reactive Java IoT Demo - BGOUG 2018
IPT Reactive Java IoT Demo - BGOUG 2018
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
 
RDF Stream Processing: Let's React
RDF Stream Processing: Let's ReactRDF Stream Processing: Let's React
RDF Stream Processing: Let's React
 
Reactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiReactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary Grygleski
 
Reactive mesh
Reactive meshReactive mesh
Reactive mesh
 

More from Fabio Tiriticco

Intro slides - Global Reactive Meetup - Move over JDBC!
Intro slides - Global Reactive Meetup - Move over JDBC!Intro slides - Global Reactive Meetup - Move over JDBC!
Intro slides - Global Reactive Meetup - Move over JDBC!
Fabio Tiriticco
 
Planespotting - From Zero To Deep Learning
Planespotting - From Zero To Deep Learning Planespotting - From Zero To Deep Learning
Planespotting - From Zero To Deep Learning
Fabio Tiriticco
 
From Zero To Deep Learning With Scala
From Zero To Deep Learning With ScalaFrom Zero To Deep Learning With Scala
From Zero To Deep Learning With Scala
Fabio Tiriticco
 
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus IntroReactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Fabio Tiriticco
 
Ten Frustrations From The Community Trenches (And How To Deal With Them)
Ten Frustrations From The Community Trenches (And How To Deal With Them)Ten Frustrations From The Community Trenches (And How To Deal With Them)
Ten Frustrations From The Community Trenches (And How To Deal With Them)
Fabio Tiriticco
 
We all need friends and Akka just found Kubernetes
We all need friends and Akka just found KubernetesWe all need friends and Akka just found Kubernetes
We all need friends and Akka just found Kubernetes
Fabio Tiriticco
 
Cloud native akka and kubernetes holy grail to elasticity
Cloud native akka and kubernetes   holy grail to elasticityCloud native akka and kubernetes   holy grail to elasticity
Cloud native akka and kubernetes holy grail to elasticity
Fabio Tiriticco
 
Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!
Fabio Tiriticco
 
Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)
Fabio Tiriticco
 
Beyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingBeyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor Programming
Fabio Tiriticco
 
Akka Streams at Weeronline
Akka Streams at WeeronlineAkka Streams at Weeronline
Akka Streams at Weeronline
Fabio Tiriticco
 

More from Fabio Tiriticco (11)

Intro slides - Global Reactive Meetup - Move over JDBC!
Intro slides - Global Reactive Meetup - Move over JDBC!Intro slides - Global Reactive Meetup - Move over JDBC!
Intro slides - Global Reactive Meetup - Move over JDBC!
 
Planespotting - From Zero To Deep Learning
Planespotting - From Zero To Deep Learning Planespotting - From Zero To Deep Learning
Planespotting - From Zero To Deep Learning
 
From Zero To Deep Learning With Scala
From Zero To Deep Learning With ScalaFrom Zero To Deep Learning With Scala
From Zero To Deep Learning With Scala
 
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus IntroReactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
 
Ten Frustrations From The Community Trenches (And How To Deal With Them)
Ten Frustrations From The Community Trenches (And How To Deal With Them)Ten Frustrations From The Community Trenches (And How To Deal With Them)
Ten Frustrations From The Community Trenches (And How To Deal With Them)
 
We all need friends and Akka just found Kubernetes
We all need friends and Akka just found KubernetesWe all need friends and Akka just found Kubernetes
We all need friends and Akka just found Kubernetes
 
Cloud native akka and kubernetes holy grail to elasticity
Cloud native akka and kubernetes   holy grail to elasticityCloud native akka and kubernetes   holy grail to elasticity
Cloud native akka and kubernetes holy grail to elasticity
 
Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!
 
Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)
 
Beyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingBeyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor Programming
 
Akka Streams at Weeronline
Akka Streams at WeeronlineAkka Streams at Weeronline
Akka Streams at Weeronline
 

Recently uploaded

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

Reactive in Android and Beyond Rx

Editor's Notes

  1. I work both as an Android and Scala engineer. I mostly use scala for backend applications. Those are a few of the companies that I worked for over the past few years. Some time ago, I got so fascinated by this Reactive concept that …
  2. The Reactive principles are cross-technology and cross-domain, so I basically started this meetup..
  3. If we look up “Reactive” in the vocabulary, it is an adjective meaning [READ] Upon mentioning this word to people in technology, this word somehow comes across as confusing. I think the root is that it can be used in (at least) two context:
  4. The paradigm is more supportive of reasoning about problems in concurrent and parallelized applications. At its core, functional programming encourages the use of pure functions, that is a function that returns the same value every time when passed the same inputs and without side effects. Side effects are operations inside a function that act on things outside a function. Maybe modifying some state, or inserting data in the storage. Functions with no side effects are easier to reason about, especially in complex systems. Immutability: mutable state can be dangerous and therefore state mutation should be confined as much as possible. Higher order functions - in functional languages, functions can exist as first-class citizens. Meaning that a function can be passed around into another function. This makes the code more composable.
  5. Func1 is an implementation of an interface, with a method “call” that takes a string as a parameter and returns its length. Using lambdas, we can rewrite it as… and because the body of the method has a single instruction we can further simplify it like this.
  6. In the coming examples we will use this simple object: a cat with a name, a color and whose picture we can fetch from some server online.
  7. The Observable class in RxJava has a “from” static method that takes a collection as an input and will output its items one by one. This is called an “Observable”: a stream of data. In our case, a stream of cats. In order to do something with these items, we need to subscribe through the subscribe function. The subscribe function takes as a parameter the implementation of an interface which takes a cat as an input and does something with it. And it’s usually chained. You might be wondering “if I want to do something with each cat, I can do it in a classic for-loop”. This is true for these simple examples, but the beauty of RxJava is that it allows you to manipulate the stream without breaking it, and late we’ll see even more reasons.
  8. In this example we use the map operator from RxJava. This operator lets you change the item that gets propagated through the stream. The map operator takes another function whose return type can be different than the input type. In this case we take a cat and return a color. The subscribe at the end now has a color as input.
  9. Because a stream is potentially endless, at some point you might want to unsubscribe. The subscribe function actually returns a Subscription. We can use this subscription later to unsubscribe from the stream. In the beginning we mentioned that RxJava makes threading easy, so let’s look at how that works.
  10. …and you can even create your own, which can be difficult to get right but it’s a lot of fun. So, in my experience, using RxJava in Android leads to cleaner and more maintainable code plus it’s actually fun! But there are also disadvantages…
  11. ..if we want to use this in an Android app,
  12. The FlatMap operator that you see on the second line is similar to map: it takes an input (in this case the response body of the request) but instead of returning another type, it returns an observable of another type. Basically the “events” function takes the responseBody as input, parses the chunks into separate events and emits them as they come. And this will be the observable that we subscribe to at the end.
  13. [END] this has come in response to the evolution of internet usage:
  14. As the user base of web services grew, different frameworks and tools came along. The one we’ll be talking about here is the Reactive Manifesto, which defines a sort of design guideline to build reactive systems: it describes a few traits that a system should have in order to be reactive. What are the traits of reactive systems?
  15. These traits are somehow interconnected. Now, if we look at these traits one by one…
  16. The load of a system can change over days, weeks or part of the year. Online store have Christmas or black friday sales. Banks might have payday and such. Elasticity means that you are able to use "just the right amount" of resources for the task. To ease out the distribution of a system, its component must be loosely coupled.
  17. It is defined as the ability of something to jump back into shape after a failure. Resilience means to restore functionality into FULL CAPACITY, and not just crawl on. We want to heal fully. Get hit - survive and keep going: this is FAULT TOLERANCE. The problem with this is that it isn't a sustainable strategy. What we need is RESILIENCE. Resilience goes beyond fault tolerance.
  18. One thing that we'll encounter when designing these systems, is that we'll concentrate on Messages. If only messages are exchanged between components, we have achieved separation and error containment. Focus shifts from class diagrams and interface definitions to message flow: the protocol that defines the conversation between components. Who says what at what time. The idea is that each component doesn’t share its internal state. In the real world, we don't read in each other's brains. Not yet at least. We use communication.
  19. An actor is an isolated component that contains State, Behavior, a Mailbox, Children and a Supervisor. The supervisor is especially important for error containment and resilience.
  20. In a typical Java app you would see something like this. What you need to do here is run this code in a separate thread.
  21. Maybe getAllCats() could take a callback. In this case, we need some additional mechanism to signal failures, and the threading is a bit mysterious, plus callbacks can end up in the mythical callback hell
  22. In a typical Java app you would see something like this. What you need to do here is run this code in a separate thread.Maybe getAllCats() could take a callback
  23. … the activity will also have a similar method that receives a Result message and does something with it.
  24. .. recovery which might be more expensive: catch exceptions, store statistics etc. The goal of the restart is to wipe all the state that the component has grown into. Trying to recover from sketchy states can be tricky and generate even more mess.
  25. Decoupling and failure containment is really important as it enables supervision and actor could be restarted by the supervisor. Failure WILL happen, so fault-avoidance is doomed. The only thing we can do is embrace failure and gracefully deal with the consequences.
  26. I reckon you might be more confused than when I started. That’s possibly a good thing.