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
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
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
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
object SwipeToRefreshIntent : CountryListIntent() data class AddToFavoriteIntent( val countryName: String) : CountryListIntent() data class RemoveFromFavoriteIntent( val countryName: String) : CountryListIntent() data class ChangeFilterIntent( val filterType: FilterType) : 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() }}
filterType: FilterType? ) : CountryListAction() data class ( val countryName: String ) : CountryListAction() data class ( val countryName: String ) : CountryListAction() } RemoveFromFavoriteAction AddToFavoriteAction 58 LoadCountriesAction CountryListAction ACTIONS
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
result: CountryListResult -> when (result) {{ is LoadCountriesResult -> when (result) {{ is LoadCountriesResult.Success -> /***/ is LoadCountriesResult.Failure -> 80 /***/ /***/ is LoadCountriesResult.InProgress -> }} is AddToFavoriteResult -> /***/ is RemoveFromFavoriteResult -> /***/ }} }} }}
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