Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
1
MVVM and
RxJava –
the perfect
mix
Florina Muntenescu
Droidcon Zagreb 2016
2
What and who upday is
3
When did we
decide to go
the RxJava &
MVVM way?
4
The old app
When did we decide to go the RxJava & MVVM way?
5
The old app
When did we decide to go the RxJava & MVVM way?
99 little bugs in the code.
99 little bugs in the code.
Take...
6
From the old to the new
When did we decide to go the RxJava & MVVM way?
7
Crash course
in RxJava
8
Sum it up!
Crash course in RxJava
A1 0
A2 2
C1 3
combineLatest( (A1,A2) => A1+A2)
0
0
1
1
9
What is MVVM
and how do
you apply it?
10
Model-View-Presenter
What is MVVM and how do you apply it?
ModelView Presenter
IView IPresenter
1 … 1
11
Model-View-ViewModel
What is MVVM and how do you apply it?
DataModelView ViewModel
1 … *
12
What is MVVM and how do you apply it?
13
Model-View-ViewModel
What is MVVM and how do you apply it?
DataModelView ViewModel
1 … *
14
Testing
What is MVVM and how do you apply it?
15
Model-View-ViewModel
What is MVVM and how do you apply it?
DataModel
1 … *
View ViewModel
1 … *
View ViewModel
1 … *
Vi...
16
What is MVVM and how do you apply it?
1 … *
Function
View
Function
ViewModel1 … *Spreadsheet
View
Spreadsheet
ViewModel...
17
What is MVVM and how do you apply it?
1 … 1
Function
View
implements
IFunctionView
Function
Presenter1 … 1Spreadsheet
V...
18
19
We made
mistakes but
we recovered!
20
We made mistakes but we recovered!
21
View
We made mistakes but we recovered!
22
ViewModel
We made mistakes but we recovered!
23
View
We made mistakes but we recovered!
24
We made mistakes but we recovered!
What about Views that don’t have have lifecycle
events?
25
We made mistakes but we recovered!
Views and subscriptions
26
We made mistakes but we recovered!
Views and subscriptions
27
28
RxJava – the
good and the
bad
29
RxJava – the good and the bad
RxJava vs Threads/AsyncTask/Event bus frameworks
30
Stream
composability FTW!
RxJava – the good and the bad
31
Split a string using a regular expression and append a
new line to each item in the resulting list
RxJava – the good an...
32
RxJava – the good and the bad
map(line -> line.trim() + NEW_LINE)
toList()
“RxJava“
…
“the“ “good“
“RxJavan “
…
“then“ ...
33
Split a string using a regular expression and append a
new line to each item in the resulting list
RxJava – the good an...
34
3535
Simple MVVM example: https://github.com/florina-muntenescu/DroidconMVVM
MVP vs MVVM example: https://github.com/flori...
Upcoming SlideShare
Loading in …5
×

MVVM and RxJava – the perfect mix

14,966 views

Published on

Slides for Droidcon Zagreb 2016 "MVVM and RxJava – the perfect mix" talk

Published in: Technology

MVVM and RxJava – the perfect mix

  1. 1. 1 MVVM and RxJava – the perfect mix Florina Muntenescu Droidcon Zagreb 2016
  2. 2. 2 What and who upday is
  3. 3. 3 When did we decide to go the RxJava & MVVM way?
  4. 4. 4 The old app When did we decide to go the RxJava & MVVM way?
  5. 5. 5 The old app When did we decide to go the RxJava & MVVM way? 99 little bugs in the code. 99 little bugs in the code. Take one down, patch it around. 127 little bugs in the code…
  6. 6. 6 From the old to the new When did we decide to go the RxJava & MVVM way?
  7. 7. 7 Crash course in RxJava
  8. 8. 8 Sum it up! Crash course in RxJava A1 0 A2 2 C1 3 combineLatest( (A1,A2) => A1+A2) 0 0 1 1
  9. 9. 9 What is MVVM and how do you apply it?
  10. 10. 10 Model-View-Presenter What is MVVM and how do you apply it? ModelView Presenter IView IPresenter 1 … 1
  11. 11. 11 Model-View-ViewModel What is MVVM and how do you apply it? DataModelView ViewModel 1 … *
  12. 12. 12 What is MVVM and how do you apply it?
  13. 13. 13 Model-View-ViewModel What is MVVM and how do you apply it? DataModelView ViewModel 1 … *
  14. 14. 14 Testing What is MVVM and how do you apply it?
  15. 15. 15 Model-View-ViewModel What is MVVM and how do you apply it? DataModel 1 … * View ViewModel 1 … * View ViewModel 1 … * View ViewModel 1 … * View ViewModel
  16. 16. 16 What is MVVM and how do you apply it? 1 … * Function View Function ViewModel1 … *Spreadsheet View Spreadsheet ViewModelObservable<String> getFunctionText()
  17. 17. 17 What is MVVM and how do you apply it? 1 … 1 Function View implements IFunctionView Function Presenter1 … 1Spreadsheet View Spreadsheet Presenter implements IFunctionView void textUpdated(String)
  18. 18. 18
  19. 19. 19 We made mistakes but we recovered!
  20. 20. 20 We made mistakes but we recovered!
  21. 21. 21 View We made mistakes but we recovered!
  22. 22. 22 ViewModel We made mistakes but we recovered!
  23. 23. 23 View We made mistakes but we recovered!
  24. 24. 24 We made mistakes but we recovered! What about Views that don’t have have lifecycle events?
  25. 25. 25 We made mistakes but we recovered! Views and subscriptions
  26. 26. 26 We made mistakes but we recovered! Views and subscriptions
  27. 27. 27
  28. 28. 28 RxJava – the good and the bad
  29. 29. 29 RxJava – the good and the bad RxJava vs Threads/AsyncTask/Event bus frameworks
  30. 30. 30 Stream composability FTW! RxJava – the good and the bad
  31. 31. 31 Split a string using a regular expression and append a new line to each item in the resulting list RxJava – the good and the bad “RxJava – the good and the bad” [“RxJavan”, “then”, “goodn”, ”andn”, “then”, ”badn”]
  32. 32. 32 RxJava – the good and the bad map(line -> line.trim() + NEW_LINE) toList() “RxJava“ … “the“ “good“ “RxJavan “ … “then“ “goodn“ ["RxJavan“, “then“, “goodn“ ...]
  33. 33. 33 Split a string using a regular expression and append a new line to each item in the resulting list RxJava – the good and the bad
  34. 34. 34
  35. 35. 3535 Simple MVVM example: https://github.com/florina-muntenescu/DroidconMVVM MVP vs MVVM example: https://github.com/florina-muntenescu/MVPvsMVVM Exclusive to Samsung

×