Share
Embed
MVI
Introduction and application of the reactive MVI architecture in the Android world.
Iveta Jurcikova
December 11, 2018
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
195 slides
-
WHAT IS THE “MODEL”? • Responsible for handling the business
logic • It is where your business logic and application data is stored • It is an interface responsible for managing data • Represents the data and business logic of the app • Gateway to your domain layer or business logic 3 -
WHAT IS THE “MODEL”? • Responsible for handling the business
logic • It is where your business logic and application data is stored • It is an interface responsible for managing data • Represents the data and business logic of the app • Gateway to your domain layer or business logic 3 -
• First defined by Trygve Reenskaug in 1979 • “Model
is responsible for representing state, structure and behaviour of the user’s mental model.” MVC 5 -
• First defined by Trygve Reenskaug in 1979 • “Model
is responsible for representing state, structure and behaviour of the user’s mental model.” • “A View presents information that it retrieves from one or more model objects.” MVC 5 -
• First defined by Trygve Reenskaug in 1979 • “Model
is responsible for representing state, structure and behaviour of the user’s mental model.” • “A View presents information that it retrieves from one or more model objects.” • “Let the View register with the Model as being a dependent of the Model, and let the Model send appropriate messages to its dependents whenever it changes.” MVC 5 -
PURE FUNCTION 23 view(model(intent()))) fun sum(a: Int, b: Int): Int
{ return a + b }} -
PURE FUNCTION 23 view(model(intent()))) fun sum(a: Int, b: Int): Int
{ return a + b }} fun sum(a: Int, b: Int): Int { println(a + b) return a + b } -
PURE FUNCTION 24 view(model(intent()))) fun sum(a: Int, b: Int): Int
{ return a + b }} var b = 0 fun sum(a: Int): Int { return a + b } -
PURE FUNCTION 24 view(model(intent()))) fun sum(a: Int, b: Int): Int
{ return a + b }} var b = 0 fun sum(a: Int): Int { return a + b } -
STATE 29 • Immutable data structure • Single source of
truth • intent() for each change ➡ Clear understanding of what happens in the app -
STATE 32 1 x 1 class CountryListViewState(( val isLoading =
false,,, val countries = emptyList())) -
STATE 32 1 x 1 class CountryListViewState(( val isLoading =
false,,, val countries = emptyList())) -
STATE 32 1 x 1 class CountryListViewState(( val isLoading =
false,, , val countries = emptyList(), val isRefreshing = true)) -
STATE 33 class CountryListViewState(( val isLoading = false,, , val
countries = emptyList(), val isRefreshing = true)) -
STATE 33 class CountryListViewState(( val isLoading = false,, , val
countries = emptyList(), val isRefreshing = true)) -
class CountryListViewState(( val isLoading = false,, , val countries =
emptyList(), val isRefreshing = true, val error = `UnknownHostException…`)) STATE 33 -
class CountryListViewState(( val isLoading = false,, , val countries =
emptyList(), val isRefreshing = true, val error = `UnknownHostException…`)) STATE 33 -
STATE PROBLEM class MyProfileViewModel {{ val progress = MutableLiveData() val
myProfile = MutableLiveData() override fun loadProfile() {{ progress.value = true subscriptions.add( myProfileInteractor.getLoggedUser().subscribe(( object : Subscriber<UserEntity>() {{ override fun onCompleted() {{ progress.value = false }} override fun onError(e: Throwable) {{ handleError(e) }} override fun onNext(userEntity: UserEntity) {{ userInteractor.setUser(userEntity) myProfile.value = userEntity }} }} )) )) }} override fun handleEditProfileClick() {{ /***/ }} }} 35 -
STATE PROBLEM class MyProfileViewModel {{ val progress = MutableLiveData() val
myProfile = MutableLiveData() override fun loadProfile() {{ progress.value = true subscriptions.add( myProfileInteractor.getLoggedUser().subscribe(( object : Subscriber<UserEntity>() {{ override fun onCompleted() {{ progress.value = false }} override fun onError(e: Throwable) {{ handleError(e) }} override fun onNext(userEntity: UserEntity) {{ userInteractor.setUser(userEntity) myProfile.value = userEntity }} }} )) )) }} override fun handleEditProfileClick() {{ /***/ }} }} 35 STATE PROBLEM -
class MyProfileViewModel {{ val progress = MutableLiveData() val myProfile =
MutableLiveData() override fun loadProfile() {{ progress.value = true subscriptions.add( myProfileInteractor.getLoggedUser().subscribe(( object : Subscriber<UserEntity>() {{ override fun onCompleted() {{ progress.value = false }} override fun onError(e: Throwable) {{ handleError(e) }} override fun onNext(userEntity: UserEntity) {{ userInteractor.setUser(userEntity) myProfile.value = userEntity }} }} )) )) }} override fun handleEditProfileClick() {{ /***/ }} }} 36 STATE PROBLEM -
37 STATE PROBLEM class MyProfileViewModel {{ val progress = MutableLiveData()
val myProfile = MutableLiveData() override fun loadProfile() {{ progress.value = true subscriptions.add( myProfileInteractor.getLoggedUser().subscribe(( object : Subscriber<UserEntity>() {{ override fun onCompleted() {{ progress.value = false }} override fun onError(e: Throwable) {{ handleError(e) }} override fun onNext(userEntity: UserEntity) {{ userInteractor.setUser(userEntity) myProfile.value = userEntity }} }} )) )) }} override fun handleEditProfileClick() {{ /***/ }} }} -
38 STATE PROBLEM class MyProfileViewModel {{ val progress = MutableLiveData()
val myProfile = MutableLiveData() override fun loadProfile() {{ progress.value = true subscriptions.add(( myProfileInteractor.getLoggedUser().subscribe(( object : Subscriber<UserEntity>() {{ override fun onCompleted() {{ progress.value = false }} override fun onError(e: Throwable) {{ handleError(e) }} override fun onNext(userEntity: UserEntity) {{ userInteractor.setUser(userEntity) myProfile.value = userEntity }} }} )) )) }} override fun handleEditProfileClick() {{ /***/ }} }} -
39 STATE PROBLEM class MyProfileViewModel {{ val progress = MutableLiveData()
val myProfile = MutableLiveData() override fun loadProfile() {{ progress.value = true subscriptions.add( myProfileInteractor.getLoggedUser().subscribe(( object : Subscriber<UserEntity>() {{ override fun onCompleted() {{ progress.value = false }} override fun onError(e: Throwable) {{ handleError(e) }} override fun onNext(userEntity: UserEntity) {{ userInteractor.setUser(userEntity) myProfile.value = userEntity }} }} )) )) }} override fun handleEditProfileClick() {{ /***/ }} }} -
47 • Start the screen • Refresh the screen •
Add country to the favourite list INTENTS -
47 • Start the screen • Refresh the screen •
Add country to the favourite list • Remove country from the favourite list INTENTS -
47 • Start the screen • Refresh the screen •
Add country to the favourite list • Remove country from the favourite list • Apply filters INTENTS -
48 INTENTS sealed class CountryListIntent {{ object InitialIntent : CountryListIntent()
object SwipeToRefreshIntent : CountryListIntent() data class AddToFavoriteIntent( val countryName: String) : CountryListIntent() data class RemoveFromFavoriteIntent( val countryName: String) : CountryListIntent() data class ChangeFilterIntent( val filterType: FilterType) : CountryListIntent() }} -
48 INTENTS sealed class CountryListIntent {{ object InitialIntent : CountryListIntent()
object SwipeToRefreshIntent : CountryListIntent() data class AddToFavoriteIntent( val countryName: String) : CountryListIntent() data class RemoveFromFavoriteIntent( val countryName: String) : CountryListIntent() data class ChangeFilterIntent( val filterType: FilterType) : CountryListIntent() }} -
class CountryListFragment {{ fun intents() = initialIntent private val initialIntent
by lazy {{ Observable.just(CountryListIntent.InitialIntent)) }} }} 51 -
class CountryListFragment {{ fun intents() = Observable.merge(( initialIntent, swipeToRefreshIntent ))
private val swipeToRefreshIntent by lazy { binding.swiperefresh.refreshes() .map { SwipeToRefreshIntent } }} }} 52 -
53 class CountryListFragment {{ fun intents() = Observable.merge(( initialIntent, swipeToRefreshIntent,
addToFavoriteIntent, removeFromFavoriteIntent ).mergeWith(changeFilterIntent)} }}} -
55 16 x 9 / 1 x 1 Intent Action
USER INTERFACE VIEW MODEL intent() actionFromIntent() -
• Load countries • Add country to the favorite list
• Remove country from the favorite list 57 ACTIONS -
sealed class { data class ( val isRefreshing: Boolean, val
filterType: FilterType? ) : CountryListAction() data class ( val countryName: String ) : CountryListAction() data class ( val countryName: String ) : CountryListAction() } RemoveFromFavoriteAction AddToFavoriteAction 58 LoadCountriesAction CountryListAction ACTIONS -
class CountryListViewModel {{ val actions: Observable<CountryListViewState> = intentsSubject .map(this::actionFromIntent) fun
actionFromIntent(intent: CountryListIntent): = when (intent) {{ is InitialIntent -> (false) is SwipeToRefreshIntent -> (true) is ChangeFilterIntent -> (intent.filterType) is AddToFavoriteIntent -> (intent.countryName) is RemoveFromFavoriteIntent -> (intent.countryName) }} }} RemoveFromFavoriteAction AddToFavoriteAction 59 LoadCountriesAction LoadCountriesAction LoadCountriesAction CountryListAction ACTIONS -
class CountryListViewModel {{ val actions: Observable<CountryListViewState> = intentsSubject .map(this::actionFromIntent) fun
actionFromIntent(intent: CountryListIntent): = when (intent) {{ is InitialIntent -> (false) is SwipeToRefreshIntent -> (true) is ChangeFilterIntent -> (intent.filterType) is AddToFavoriteIntent -> (intent.countryName) is RemoveFromFavoriteIntent -> (intent.countryName) }} }} RemoveFromFavoriteAction AddToFavoriteAction 60 LoadCountriesAction LoadCountriesAction LoadCountriesAction CountryListAction ACTIONS -
class CountryListViewModel {{ val actions: Observable<CountryListViewState> = intentsSubject .map(this::actionFromIntent) fun
actionFromIntent(intent: CountryListIntent): = when (intent) {{ is InitialIntent -> (false) is SwipeToRefreshIntent -> (true) is ChangeFilterIntent -> (intent.filterType) is AddToFavoriteIntent -> (intent.countryName) is RemoveFromFavoriteIntent -> (intent.countryName) }} }} RemoveFromFavoriteAction AddToFavoriteAction 61 LoadCountriesAction LoadCountriesAction LoadCountriesAction CountryListAction ACTIONS -
class CountryListViewModel {{ val actions: Observable<CountryListViewState> = intentsSubject .map(this::actionFromIntent) fun
actionFromIntent(intent: CountryListIntent): = when (intent) {{ is InitialIntent -> (false) is SwipeToRefreshIntent -> (true) is ChangeFilterIntent -> (intent.filterType) is AddToFavoriteIntent -> (intent.countryName) is RemoveFromFavoriteIntent -> (intent.countryName) }} }} RemoveFromFavoriteAction AddToFavoriteAction 61 LoadCountriesAction LoadCountriesAction LoadCountriesAction CountryListAction ACTIONS -
62 sealed class CountryListIntent { object InitialIntent : CountryListIntent() object
SwipeToRefresh : CountryListIntent() data class ChangeFilterIntent( val filterType: FilterType): CountryListIntent() data class AddToFavoriteIntent( val countryName: String): CountryListIntent() data class RemoveFromFavoriteIntent( val countryName: String): CountryListIntent() } sealed class CountryListAction { data class LoadCountriesAction( val isRefreshing: Boolean, val filterType: FilterType) : CountryListAction() data class AddToFavoriteAction( val countryName: String) : CountryListAction() data class RemoveFromFavoriteAction( val countryName: String) : CountryListAction() } 5 3 -
63 16 x 9 / 1 x 1 Intent Action
USER INTERFACE VIEW MODEL intent() actionFromIntent() -
66 16 x 9 / 1 x 1 Intent Action
USER INTERFACE VIEW MODEL intent() actionFromIntent() -
66 16 x 9 / 1 x 1 Intent Action
USER INTERFACE VIEW MODEL intent() actionFromIntent() -
67 16 x 9 / 1 x 1 Intent Action
Result USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() -
69 class CountryListInteractor { val actionProcessor = ObservableTransformer<CountryListAction, CountryListResult> {
actions -> actions.publish { selector -> Observable.merge(( )) }} }} }} -
70 class CountryListInteractor { val actionProcessor = ObservableTransformer<CountryListAction, CountryListResult> {
actions -> actions.publish { selector -> Observable.merge(( selector.ofType(LoadCountriesAction::class.java).compose( ), selector.ofType(AddToFavoriteAction::class.java).compose(addToFavorite), selector.ofType(RemoveFromFavoriteAction::class.java).compose(removeFromFavorite) )) }} }}} }} loadCountries -
71 val = ObservableTransformer<LoadCountriesAction, CountryListResult> { actions -> actions.flatMap {
action -> }} }}} loadCountries -
72 val loadCountries = ObservableTransformer<LoadCountriesAction, CountryListResult> { actions -> actions.flatMap
{ action -> countryRepository.getAllCountries() }} }}} -
73 val loadCountries = ObservableTransformer<LoadCountriesAction, CountryListResult> { actions -> actions.flatMap
{ action -> countryRepository.getAllCountries() .map { countries -> LoadCountriesResult.Success(countries) } }} }}} -
74 val loadCountries = ObservableTransformer<LoadCountriesAction, CountryListResult> { actions -> actions.flatMap
{ action -> countryRepository.getAllCountries() .map { countries -> LoadCountriesResult.Success(countries) } .onErrorReturn { LoadCountriesResult.Failure(it) } }} }}} -
75 val loadCountries = ObservableTransformer<LoadCountriesAction, CountryListResult> { actions -> actions.flatMap
{ action -> countryRepository.getAllCountries() .map { countries -> LoadCountriesResult.Success(countries) } .onErrorReturn { LoadCountriesResult.Failure(it) } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) }} }}} -
76 val loadCountries = ObservableTransformer<LoadCountriesAction, CountryListResult> { actions -> actions.flatMap
{ action -> countryRepository.getAllCountries() .map { countries -> LoadCountriesResult.Success(countries) } .onErrorReturn { LoadCountriesResult.Failure(it) } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .startWith(LoadCountriesResult.InProgress(action.isRefreshing)) }} }}} -
77 16 x 9 / 1 x 1 Intent Action
Result USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() -
77 16 x 9 / 1 x 1 Intent Action
Result USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() -
78 16 x 9 / 1 x 1 Intent Action
Result State USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() reducer() -
REDUX • A predicable state container • Basics • State
• Action • Reducer 79 -
REDUX • A predicable state container • Basics • State
• Action • Reducer 79 Result Old State New State f(previousState, action) = newState -
REDUX • A predicable state container • Basics • State
• Action • Reducer • Advanced 79 Result Old State New State f(previousState, action) = newState -
REDUX • A predicable state container • Basics • State
• Action • Reducer • Advanced • Middleware 79 Result Old State New State f(previousState, action) = newState -
REDUX • A predicable state container • Basics • State
• Action • Reducer • Advanced • Middleware 79 Result Old State New State f(previousState, action) = newState -
class CountryListViewModel { val reducer = BiFunction { previousState: CountryListViewState,
result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> /***/ is LoadCountriesResult.Failure -> 80 /***/ /***/ is LoadCountriesResult.InProgress -> }} is AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} -
/***/ /***/ is LoadCountriesResult.Failure -> is LoadCountriesResult.InProgress -> }} is
AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} class CountryListViewModel { val reducer = BiFunction { previousState: CountryListViewState, result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> {1 previousState.copy(1 isLoading = false, isRefreshing = false, countries = result.countries, error = null )1 }} 81 -
/***/ /***/ is LoadCountriesResult.Failure -> is LoadCountriesResult.InProgress -> }} is
AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} class CountryListViewModel { val reducer = BiFunction { previousState: CountryListViewState, result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> {1 previousState.copy(1 isLoading = false, isRefreshing = false, countries = result.countries, error = null )1 }} 81 -
class CountryListViewModel { val reducer = BiFunction { previousState: CountryListViewState,
result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> {1 previousState.copy(1 isLoading = false, isRefreshing = false, countries = result.countries, error = null )1 }} {2 2previousState.copy(2 2isLoading = false, error = result.error )2 }} /***/ is LoadCountriesResult.InProgress -> }} is AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} 82 is LoadCountriesResult.Failure -> -
class CountryListViewModel { val reducer = BiFunction { previousState: CountryListViewState,
result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> {1 previousState.copy(1 isLoading = false, isRefreshing = false, countries = result.countries, error = null )1 }} {2 2previousState.copy(2 2isLoading = false, error = result.error )2 }} /***/ is LoadCountriesResult.InProgress -> }} is AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} 82 is LoadCountriesResult.Failure -> -
{3 if (result.isRefreshing) {3 3previousState.copy(3 3isLoading = false, isRefreshing =
true )31 } else {3 previousState.copy(3 isLoading = true, isRefreshing = false )32 }3 }3 83 is LoadCountriesResult.InProgress -> val reducer = BiFunction { previousState: CountryListViewState, result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> {2 2previousState.copy(2 2isLoading = false, error = result.error )2 }} is LoadCountriesResult.Failure -> }} is AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} {1 previousState.copy(1 isLoading = false, isRefreshing = false, countries = result.countries, error = null )1 }} -
{3 if (result.isRefreshing) {3 3previousState.copy(3 3isLoading = false, isRefreshing =
true )31 } else {3 previousState.copy(3 isLoading = true, isRefreshing = false )32 }3 }3 83 is LoadCountriesResult.InProgress -> val reducer = BiFunction { previousState: CountryListViewState, result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> {2 2previousState.copy(2 2isLoading = false, error = result.error )2 }} is LoadCountriesResult.Failure -> }} is AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }} {1 previousState.copy(1 isLoading = false, isRefreshing = false, countries = result.countries, error = null )1 }} -
84 16 x 9 / 1 x 1 Intent Action
Result State USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() reducer() -
84 16 x 9 / 1 x 1 Intent Action
Result State USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() reducer() -
85 16 x 9 / 1 x 1 Intent Action
Result State USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() render() reducer() -
86 } } } class CountryListFragment { fun render(state: CountryListViewState)
{ if (state.message != null) { showMessage(state.message) }} if (state.error != null) { showErrorMessage(state.error) binding.progress.visibility = if (state.isLoading) View.VISIBLE else View.GONE binding.tvEmpty.visibility = if (!state.isLoading && state.countries.isEmpty()) View.VISIBLE else View.GONE binding.swiperefresh.isRefreshing = state.isRefreshing (binding.rvCountries.adapter as ListAdapter<Country, CountryViewHolder>) .submitList(state.countries) -
if (state.message != null) { showMessage(state.message) }} if (state.error !=
null) { showErrorMessage(state.error) 87 } } } class CountryListFragment { fun render(state: CountryListViewState) { binding.model = state -
88 16 x 9 / 1 x 1 Intent Action
Result State USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() render() reducer() -
88 16 x 9 / 1 x 1 Intent Action
Result State USER INTERFACE VIEW MODEL DATABASE/API intent() actionFromIntent() actionProcessor() render() reducer() -
91 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } -
92 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) -
92 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) -
93 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) .scan(CountryListViewState.idle(), reducer) -
93 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) .scan(CountryListViewState.idle(), reducer) -
94 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) .scan(CountryListViewState.idle(), reducer) .subscribe { viewState -> render(viewState) } -
94 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) .scan(CountryListViewState.idle(), reducer) .subscribe { viewState -> render(viewState) } Unidirectional data flow -
94 Intent Action Result State DATABASE/API intents() .map { intent
-> actionFromIntent(intent) } .compose(countryListInteractor.actionProcessor) .scan(CountryListViewState.idle(), reducer) .subscribe { viewState -> render(viewState) } Unidirectional data flow More predictable Easier to understand -
LIBRARIES • Mobius - Spotify • MvRx - Airbnb •
StateMachine - Tinder • MVICore - Badoo • RxRedux - Freeletics • Elmdroid - Inventi 97 -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability CONS SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability CONS ❌ Lot of boilerplate SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability CONS ❌ Lot of boilerplate ❌ Complexity SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability CONS ❌ Lot of boilerplate ❌ Complexity ❌ Objects creation SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability CONS ❌ Lot of boilerplate ❌ Complexity ❌ Objects creation ❌ SingleLiveEvents SUMMARY -
98 PROS ✅ No state problem ✅ Unidirectional data flow
✅ Immutability ✅ Thread safety ✅ Share-ability ✅ Debuggability ✅ Decoupled logic ✅ Testability CONS ❌ Lot of boilerplate ❌ Complexity ❌ Objects creation ❌ SingleLiveEvents ❌ No google supported SUMMARY -
“If you like the code you have written a year
ago, you haven’t learned enough this year.“ 101 Someone really smart -
REFERENCES • Benoît Quenaudon. Model-View-Intent for Android • Garima Jain.
Why MVI? Model View Intent -- The curious case of yet another pattern • Hannes Dorfmann. Reactive apps with Model-View-Intent • Kausik Gopal. RxJava by Example - Volume 3, the Multicast Edition • Jake Wharton. Managing State with RxJava • Hannes Dorfmann. Android Software Architecture by Example • Andre Staltz. What if the user was a function? • Dan Lew. Don't break the chain: use RxJava's compose() operator. • kotlinx.coroutines • Christina Lee. Coroutines By Example • Andrea Bresolin. Kotlin coroutines vs RxJava: an initial performance test • Redux documentation 113