Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MVI - Yet Another Android Architecture Model

MVI - Yet Another Android Architecture Model

A quick introduction into MVI architecture applied for Android backed by RxKotlin and Mosby MVI 3.0

Demo code: https://github.com/AndroidIasi/Codecamp-2.0/tree/presentation/cluj_181124

Andrei Verdes

November 24, 2018
Tweet

More Decks by Andrei Verdes

Other Decks in Programming

Transcript

  1. What is MVI • MVI stands for Model View Intent

    • Invented by André Medeiros (Staltz) - Cycle.js
  2. What is MVI • MVI stands for Model View Intent

    • Invented by André Medeiros (Staltz) - Cycle.js • State machine
  3. What is MVI • MVI stands for Model View Intent

    • Invented by André Medeiros (Staltz) - Cycle.js • State machine • Immutability
  4. What is MVI • MVI stands for Model View Intent

    • Invented by André Medeiros (Staltz) - Cycle.js • State machine • Immutability • Unidirectional and Circular Data Flows
  5. • Resume screen • Refresh list • Click on the

    favorite button codecamp app lite (really lite)
  6. • Resume screen • Refresh list • Click on the

    favorite button • Click on an item codecamp app lite (really lite)
  7. • Resume screen • Refresh list • Click on the

    favorite button • Click on an item • Swipe left to <custom action> codecamp app lite (really lite)
  8. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions list result
  9. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions list result new state result 
 + 
 initial state
  10. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions loading result
  11. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions loading result result 
 + 
 initial state
  12. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions loading result new state result 
 + 
 initial state
  13. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions list result new state result 
 + 
 old state
  14. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions error result new state result 
 + 
 old state
  15. Repository Reducer State Render Interactor Intents Result Intent opens app

    resumeScreen() get sessions request sessions list result new state result 
 + 
 initial state
  16. Repository Reducer State Render Interactor Intents Result Intent clicks on

    favorite saveFavoriteSession (id: String) save favorite session
  17. Repository Reducer State Render Interactor Intents Result Intent clicks on

    favorite saveFavoriteSession (id: String) save favorite session session saved to favorites
  18. Repository Reducer State Render Interactor Intents Result Intent clicks on

    favorite saveFavoriteSession (id: String) save favorite session session saved to favorites result 
 + 
 old state
  19. Repository Reducer State Render Interactor Intents Result Intent clicks on

    favorite saveFavoriteSession (id: String) save favorite session session saved to favorites new state result 
 + 
 old state
  20. Repository Reducer State Render Interactor Intents Result Intent clicks on

    favorite saveFavoriteSession (id: String) save favorite session session saved to favorites new state result 
 + 
 old state
  21. Pros and Cons • Single source of truth • Decoupling

    • Immutability • More info!!! (render history) • boilerplate code • steep learning curve • combining multiple streams can trigger unwanted renders • startWith { Result( ) } vs startWith( Result( ) )
  22. Resources • MVI - http://hannesdorfmann.com/ • Redux-ing UI Bugs by

    Christina Lee - https:// www.youtube.com/watch?v=UsuzhTlccRk • { } vs ( ) https://medium.com/@ragdroid/rxify-the-startwith- mvi-pitfall-68764ae8946d • https://raw.githubusercontent.com/oldergod/android- architecture/todo-mvi-rxjava-kotlin/art/MVI_detail.png • https://github.com/AndroidIasi/Codecamp-2.0/tree/ presentation/cluj_181124