Download - Go reactive - Manuel Vicente Vivo
![Page 1: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/1.jpg)
Go Reactive
Manuel Vicente Vivo
@manuelvicnt
![Page 2: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/2.jpg)
What is Reactive Programming?
Go Reactive @manuelvicnt
Programming paradigm based on
Propagation of changes
Processing data flows
Can be used in a Functional style
![Page 3: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/3.jpg)
Propagation of Changes
![Page 4: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/4.jpg)
Processing Data Flows
Output of processing the different flows
Source A
Source B Source B Modified
![Page 5: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/5.jpg)
FUNCTIONAL REACTIVE
LAMBDAS
CLOSURES
COMPOSABLE
PUSH
EVENTS
ASYNCHRONOUS
@manuelvicnt Go Reactive
![Page 6: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/6.jpg)
Reactive Extensions
C#: Rx.NET
Java: RxJava
JavaScript: RxJS
Scala: RxScala
Swift: RxSwift
C++: RxCpp
Ruby: Rx.rb
Python: RxPY
Groovy: RxGroovy
Kotlin: RxKotlin
Android: RxAndroid
iOS: RxCocoa
Go Reactive @manuelvicnt
![Page 7: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/7.jpg)
RxJava http://github.com/Netflix/RxJava
“ A library for COMPOSING ASYNCHRONOUS and event-based
programs using OBSERVABLE SEQUENCES for the Java VM”
Go Reactive @manuelvicnt
![Page 8: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/8.jpg)
Components
Go Reactive @manuelvicnt
Observables: Emit Items
Subscribers: Consume Items
Common Methods: onNext
onCompleted
onError
![Page 9: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/9.jpg)
Subscribers
Go Reactive @manuelvicnt
Consume items
![Page 10: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/10.jpg)
Observables
Go Reactive @manuelvicnt
Emit items
![Page 11: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/11.jpg)
Subjects
Go Reactive @manuelvicnt
Are both an Observable and a Subscriber
![Page 12: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/12.jpg)
Operators http://rxmarbles.com
Go Reactive @manuelvicnt
Transformers map, flatMap
Filters filter, take, skip
Conditions takeWhile
Combination concat, zip
Aggregate count, toList
![Page 13: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/13.jpg)
Go Reactive @manuelvicnt
Observable
Observable
Map Operator Observable
Zip Operator
Observable seen by the Subscriber
![Page 14: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/14.jpg)
Backpressure
Go Reactive @manuelvicnt
The Observable is too fast for Subscribers
Can happen anywhere in the chain
Operators: Throttle
Debounce
![Page 15: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/15.jpg)
Testing Observables
Go Reactive @manuelvicnt
Create special cases
Observable.error()
Observable.empty()
Observable.never()
Use TestSubscriber
![Page 16: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/16.jpg)
Live Coding https://github.com/manuelvicnt/RxJava-android-structure
Fragments Subscribers
View Models Subjects
Registration API Service Observable
UserData Request Manager
Observable
Login API Service Observable
Account API Service Observable
Games API Service Observable
Authentication Request Manager
Observable
Retrofit Registration
Retrofit Login
Retrofit Account
Retrofit Games
![Page 17: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/17.jpg)
Go Reactive @manuelvicnt
1. Registration Retrofit returns
Observable
2. Registration API Service propagates the
Observable
3. User Auth RM concatenates Login Request
4. User Auth RM gets the Login Observable
5. Subscribers will get this when subscribing to Registration,
Registration & Login request will be made and the result will be a
Login Response
![Page 18: Go reactive - Manuel Vicente Vivo](https://reader031.vdocument.in/reader031/viewer/2022020314/58707fa41a28ab57368b60db/html5/thumbnails/18.jpg)
Go Reactive @manuelvicnt
1.1 Account Data from Account API Service
Observable
3. Subscriber will get the result
when both requests come
2. Zip Operator in UserData RM Observable
1.2 Games Data from Games API Service
Observable