SlideShare a Scribd company logo
Android reactive programming using agera
Android Reactive programming using
Agera
Mahmoud El-Naggar
Content
• Reactive programming
• Agera Basics
• Repositories
• Compiled repositories
• Compiled functions
• Reservoirs and parallelism
• Agera and Retrofit
• Agera vs RxJava
• References
Asynchronous Stream
It Is Writing asynchronous and event/data stream programs
using observable sequences
Reactive programming
Observable Pattern : Is Using to notify a group of listeners about data change.
Reactive Systems Characteristics :
Reactive Systems Characteristics :
1- Responsive : The application always respond to user actions.
2- Resilient : The application is responsive on state of failure.
3- Elastic : Must be responsive when data scale and increase
resources.
4- Message-Driven : Reactive programs depends on Async messages
passing when data changes or event occur to apply isolation and
loose coupling between components.
Reactive Implementations on Android
1. Google Agera : Push event, pull data Model
2. RxJava & RxAndroid : Push event, pull data Model
3. EventBus & Otto : publisher/subscriber
Reactive Programming and Data Streaming Library
Agera Basics
Google Agera : Agera (Swedish for “to act”) is lightweight
Android library for Reactive Programming Implemented by
Google Play Music Team.
Agera uses four Interfaces to implement Reactive
programming :
1. Observable : to add and remove Updatables
2. Supplier<T>: to supply data to Updatables
3. Receiver<T> : to get data from Supplier
4. Updatable : Object which be notified when data changed
Example:
Agera Basics
Example :
Repositories
Repository : Is an observable that supplies data and defines
an event as a change of the supplied data.
Repositories Types :
Simple repositories
1.1 – Static Repository
2.1 - Mutable Repositories
2. Complex repositories
Static Repository
Supply same value and doesn’t generate any events
Supply value when data changed to any number of Updatables
Mutable Repositories
• Mutable Repository Example
Repositories
2. Complex repositories :
Listen to changes in other repositories and observables and emit these
changes to other Updatables, also can apply data stream operators
when data change before notify Updatables.
Compiled repositories
Compiled repositories are complex repositories initialized in one
expression and contains these parts In this order :
1 - Repositories.repositoryWithInitialValue(...);
2 - Event sources - .observe(...);
3 - Frequency of reaction - .onUpdatesPer(...) or .onUpdatesPerLoop();
4 - Data processing flow - .getFrom(...), .mergeIn(...), .transform(...), etc.;
5 - Miscellaneous configurations - .notifyIf(...), .onDeactivation(...), etc.;
6 - .compile().
Compiled repositories
Data processing flow
The data processing flow consists of directives.
Each directive accepts an input value and produces an
output value for the next directive. The input value type
to the first directive is the repository value type, and so is
the output value type of the last directive.
Compiled functions
Compiled functions: are the operators used in data flow like
apply , map , filter and limit
Reservoirs and parallelism
A Reservoir is the reactive version of a Queue
Attempts and Result
Data flow may produce errors , so we use Result object to
get success or fail result from any operator.
These functions return Result<T>
1- attemptGetFrom(Supplier).or…;
2- attemptTransform(Function).or…;
3- attemptMergeIn(Supplier, Merger).or…,
Agera and Retrofit
Retrofit : Is a very popular HTTP client for Android
Development , and make any http request is very easy
and clear.
for Integrating Retrofit with Agera with use open source
library called Retrofit Agera call adapter
Agera and Retrofit
Retrofit object created as :
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://www.omdbapi.com/")
.client(new OkHttpClient())
.addCallAdapterFactory(AgeraCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
final Service service = retrofit.create(Service.class);
Agera and Retrofit
Define API Interface like this
interface Service {
@GET("1")
Supplier<Result<Movie>> android();
@GET("{page}")
Supplier<Result<Response<Movie>>> getMovies(@Path("page") int page);
}
Agera and Retrofit
then we initialize Repository like this
repository = Repositories.repositoryWithInitialValue(INITIAL_VALUE)
.observe()
.onUpdatesPerLoop()
.goTo(networkExecutor)
.attemptGetFrom(service.android())
.orSkip()
.thenTransform(Result.Success)
.compile();
Agera vs RxJava
Agera RxJava
Observables 1- Repository
2-MutableRepository
1- Flowable
2- Observable
3- Single
4- Maybe
Subscribers 1- Updatable 1- Observer
2- Consumer
3- Subject
Operators 1- Function.apply(TFrom)
2- Function.unpack(TFrom)
3- Function.filter(TFrom)
4- Function.map(TFrom)
5- Function.morph(TFrom)
6- Function.limit(TFrom)
7- Merger.merge(TFirst, TSecond)
filter,map,flatMap,skip,skipLast,
range,firs,tlast,min,max etc...
https://github.com/ReactiveX/RxJa
va/wiki/Alphabetical-List-of-
Observable-Operators
Resources
1. http://reactivex.io/intro.html
2. http://www.reactivemanifesto.org/
3. https://github.com/google/agera/
4. https://github.com/drakeet/retrofit-agera-call-adapter
5. https://medium.freecodecamp.com/rxandroid-and-retrofit-2-0-
66dc52725fff#.p222b0bvj
Questions ?? No :)
Thank You

More Related Content

PDF
Fabio Biondi - Front-end data architectures in Angular, Redux & NGRX - Codemo...
PDF
REST APIs for the Internet of Things
PPSX
Observer design pattern
PDF
IoT Toolkit and the Smart Object API Tutorial Introduction
PDF
Kafka presentation
PDF
The Spine project – Open source toolbox for modelling integrated energy systems
PDF
JS Experience 2017 - Reactive Interfaces com React & RxJS
PDF
Log aggragation
Fabio Biondi - Front-end data architectures in Angular, Redux & NGRX - Codemo...
REST APIs for the Internet of Things
Observer design pattern
IoT Toolkit and the Smart Object API Tutorial Introduction
Kafka presentation
The Spine project – Open source toolbox for modelling integrated energy systems
JS Experience 2017 - Reactive Interfaces com React & RxJS
Log aggragation

Similar to Android reactive programming using agera (20)

PPTX
Microservices Part 4: Functional Reactive Programming
PPTX
Functional reactive programming
PDF
Introduction to reactive programming
PDF
Predictable reactive state management - ngrx
PDF
Reactive Programming in Java and Spring Framework 5
PDF
The Meteor Framework
PDF
Reactive java - Reactive Programming + RxJava
PDF
Reactive Applications with Apache Pulsar and Spring Boot
PDF
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
PPTX
Reactive programming
PPTX
Application Timeline Server - Past, Present and Future
PPTX
Application Timeline Server - Past, Present and Future
PPTX
Intro to Reactor
PPTX
Belfast JUG 23-10-2013
PDF
Nicholas Gustilo "Clean Android: building great mobile apps"
PDF
RxJava@Android
PPTX
Application Timeline Server Past, Present and Future
PDF
Apache Big Data EU 2016: Next Gen Big Data Analytics with Apache Apex
PPTX
Stream Processing with Apache Apex
PDF
Automated Cluster Management and Recovery for Large Scale Multi-Tenant Sea...
Microservices Part 4: Functional Reactive Programming
Functional reactive programming
Introduction to reactive programming
Predictable reactive state management - ngrx
Reactive Programming in Java and Spring Framework 5
The Meteor Framework
Reactive java - Reactive Programming + RxJava
Reactive Applications with Apache Pulsar and Spring Boot
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Reactive programming
Application Timeline Server - Past, Present and Future
Application Timeline Server - Past, Present and Future
Intro to Reactor
Belfast JUG 23-10-2013
Nicholas Gustilo "Clean Android: building great mobile apps"
RxJava@Android
Application Timeline Server Past, Present and Future
Apache Big Data EU 2016: Next Gen Big Data Analytics with Apache Apex
Stream Processing with Apache Apex
Automated Cluster Management and Recovery for Large Scale Multi-Tenant Sea...
Ad

Recently uploaded (20)

PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
L1 - Introduction to python Backend.pptx
PDF
medical staffing services at VALiNTRY
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
top salesforce developer skills in 2025.pdf
Designing Intelligence for the Shop Floor.pdf
CHAPTER 2 - PM Management and IT Context
Digital Systems & Binary Numbers (comprehensive )
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Upgrade and Innovation Strategies for SAP ERP Customers
Softaken Excel to vCard Converter Software.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Operating system designcfffgfgggggggvggggggggg
L1 - Introduction to python Backend.pptx
medical staffing services at VALiNTRY
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Computer Software and OS of computer science of grade 11.pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Why Generative AI is the Future of Content, Code & Creativity?
top salesforce developer skills in 2025.pdf
Ad

Android reactive programming using agera

  • 2. Android Reactive programming using Agera Mahmoud El-Naggar
  • 3. Content • Reactive programming • Agera Basics • Repositories • Compiled repositories • Compiled functions • Reservoirs and parallelism • Agera and Retrofit • Agera vs RxJava • References
  • 4. Asynchronous Stream It Is Writing asynchronous and event/data stream programs using observable sequences
  • 5. Reactive programming Observable Pattern : Is Using to notify a group of listeners about data change.
  • 7. Reactive Systems Characteristics : 1- Responsive : The application always respond to user actions. 2- Resilient : The application is responsive on state of failure. 3- Elastic : Must be responsive when data scale and increase resources. 4- Message-Driven : Reactive programs depends on Async messages passing when data changes or event occur to apply isolation and loose coupling between components.
  • 8. Reactive Implementations on Android 1. Google Agera : Push event, pull data Model 2. RxJava & RxAndroid : Push event, pull data Model 3. EventBus & Otto : publisher/subscriber
  • 9. Reactive Programming and Data Streaming Library
  • 10. Agera Basics Google Agera : Agera (Swedish for “to act”) is lightweight Android library for Reactive Programming Implemented by Google Play Music Team. Agera uses four Interfaces to implement Reactive programming : 1. Observable : to add and remove Updatables 2. Supplier<T>: to supply data to Updatables 3. Receiver<T> : to get data from Supplier 4. Updatable : Object which be notified when data changed
  • 13. Repositories Repository : Is an observable that supplies data and defines an event as a change of the supplied data. Repositories Types : Simple repositories 1.1 – Static Repository 2.1 - Mutable Repositories 2. Complex repositories
  • 14. Static Repository Supply same value and doesn’t generate any events
  • 15. Supply value when data changed to any number of Updatables Mutable Repositories
  • 17. Repositories 2. Complex repositories : Listen to changes in other repositories and observables and emit these changes to other Updatables, also can apply data stream operators when data change before notify Updatables.
  • 18. Compiled repositories Compiled repositories are complex repositories initialized in one expression and contains these parts In this order : 1 - Repositories.repositoryWithInitialValue(...); 2 - Event sources - .observe(...); 3 - Frequency of reaction - .onUpdatesPer(...) or .onUpdatesPerLoop(); 4 - Data processing flow - .getFrom(...), .mergeIn(...), .transform(...), etc.; 5 - Miscellaneous configurations - .notifyIf(...), .onDeactivation(...), etc.; 6 - .compile().
  • 20. Data processing flow The data processing flow consists of directives. Each directive accepts an input value and produces an output value for the next directive. The input value type to the first directive is the repository value type, and so is the output value type of the last directive.
  • 21. Compiled functions Compiled functions: are the operators used in data flow like apply , map , filter and limit
  • 22. Reservoirs and parallelism A Reservoir is the reactive version of a Queue
  • 23. Attempts and Result Data flow may produce errors , so we use Result object to get success or fail result from any operator. These functions return Result<T> 1- attemptGetFrom(Supplier).or…; 2- attemptTransform(Function).or…; 3- attemptMergeIn(Supplier, Merger).or…,
  • 24. Agera and Retrofit Retrofit : Is a very popular HTTP client for Android Development , and make any http request is very easy and clear. for Integrating Retrofit with Agera with use open source library called Retrofit Agera call adapter
  • 25. Agera and Retrofit Retrofit object created as : Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://www.omdbapi.com/") .client(new OkHttpClient()) .addCallAdapterFactory(AgeraCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build(); final Service service = retrofit.create(Service.class);
  • 26. Agera and Retrofit Define API Interface like this interface Service { @GET("1") Supplier<Result<Movie>> android(); @GET("{page}") Supplier<Result<Response<Movie>>> getMovies(@Path("page") int page); }
  • 27. Agera and Retrofit then we initialize Repository like this repository = Repositories.repositoryWithInitialValue(INITIAL_VALUE) .observe() .onUpdatesPerLoop() .goTo(networkExecutor) .attemptGetFrom(service.android()) .orSkip() .thenTransform(Result.Success) .compile();
  • 28. Agera vs RxJava Agera RxJava Observables 1- Repository 2-MutableRepository 1- Flowable 2- Observable 3- Single 4- Maybe Subscribers 1- Updatable 1- Observer 2- Consumer 3- Subject Operators 1- Function.apply(TFrom) 2- Function.unpack(TFrom) 3- Function.filter(TFrom) 4- Function.map(TFrom) 5- Function.morph(TFrom) 6- Function.limit(TFrom) 7- Merger.merge(TFirst, TSecond) filter,map,flatMap,skip,skipLast, range,firs,tlast,min,max etc... https://github.com/ReactiveX/RxJa va/wiki/Alphabetical-List-of- Observable-Operators
  • 29. Resources 1. http://reactivex.io/intro.html 2. http://www.reactivemanifesto.org/ 3. https://github.com/google/agera/ 4. https://github.com/drakeet/retrofit-agera-call-adapter 5. https://medium.freecodecamp.com/rxandroid-and-retrofit-2-0- 66dc52725fff#.p222b0bvj
  • 30. Questions ?? No :) Thank You