SlideShare una empresa de Scribd logo
1 de 50
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

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 LogsNETWAYS
 
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 beyondBowen 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 Sparkdatamantra
 
Introduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkIntroduction to Streaming with Apache Flink
Introduction to Streaming with Apache FlinkTugdual 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 talkconfluent
 
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 ReactorKnoldus 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 Connectconfluent
 
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 MaDatabricks
 
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 ProcessorAljoscha Krettek
 
Rx Reactive programming
Rx Reactive programmingRx Reactive programming
Rx Reactive programminglucas34990
 
Parallel Development in VS10
Parallel Development in VS10Parallel Development in VS10
Parallel Development in VS10Valdis 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 Sparkdatamantra
 
Whats new in_mlflow
Whats new in_mlflowWhats new in_mlflow
Whats new in_mlflowDatabricks
 
SAIS2018 - Fact Store At Netflix Scale
SAIS2018 - Fact Store At Netflix ScaleSAIS2018 - Fact Store At Netflix Scale
SAIS2018 - Fact Store At Netflix ScaleNitin 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 streamingdatamantra
 
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 systemsconfluent
 
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 & KubeflowJan 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 forAljoscha 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
 

La actualidad más candente (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®
 

Destacado

WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkFabio 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 2016Mike Nakhimovich
 
Intro to Functional Programming with RxJava
Intro to Functional Programming with RxJavaIntro to Functional Programming with RxJava
Intro to Functional Programming with RxJavaMike Nakhimovich
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & designallegro.tech
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
Supercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactSupercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactJohn 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 ComparisonJosé 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-JavaKasun Indrasiri
 

Destacado (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 a RxJava Reactive Programming in Android & Beyond

Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyondFabio Tiriticco
 
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
 
RxJS vs RxJava: Intro
RxJS vs RxJava: IntroRxJS vs RxJava: Intro
RxJS vs RxJava: IntroMartin 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 2018Trayan 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 2016Trayan Iliev
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionalsTrayan Iliev
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatientGrant Steinfeld
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaAli Muzaffar
 
RxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptRxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptViliam 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 ReactorVMware Tanzu
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in DepthTrayan Iliev
 
Reactive Programming with RxJS
Reactive Programming with RxJSReactive Programming with RxJS
Reactive Programming with RxJSDanca Prima
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSupun 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 2016Trayan Iliev
 
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 2018Trayan Iliev
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveXTroy Miles
 
RDF Stream Processing: Let's React
RDF Stream Processing: Let's ReactRDF Stream Processing: Let's React
RDF Stream Processing: Let's ReactJean-Paul Calbimonte
 
Reactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiReactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiPolyglotMeetups
 

Similar a RxJava Reactive Programming in Android & Beyond (20)

Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyond
 
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 ...
 
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
 

Más de 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 ScalaFabio Tiriticco
 
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus IntroReactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus IntroFabio 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 KubernetesFabio 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 elasticityFabio 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 ProgrammingFabio Tiriticco
 
Akka Streams at Weeronline
Akka Streams at WeeronlineAkka Streams at Weeronline
Akka Streams at WeeronlineFabio Tiriticco
 

Más de 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
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

RxJava Reactive Programming in Android & Beyond

Notas del editor

  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.