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

Women Developer Academy: MVI in a nutshell

Women Developer Academy: MVI in a nutshell

PRESENTED AT:
Women Developer Academy 2021

DATE:
May 10, 2021

DESCRIPTION:
In this presentation, we will embark on a journey to explore the core principles and benefits of MVI architecture in the context of Android development. MVI is known for its clarity, testability, and scalability, making it a valuable choice for building modern, reactive, and highly interactive Android applications.

Throughout the presentation, we will demonstrate practical examples of MVI implementation, showcasing how it simplifies state management, enhances UI responsiveness, and enables cleaner, maintainable apps

MORE TALKS & ARTICLES FROM ME: https://cupsofcode.com/talks/

Aida Issayeva

May 10, 2021
Tweet

More Decks by Aida Issayeva

Other Decks in Technology

Transcript

  1. About me 󰠁 Software Engineer 🤖 I build Android apps

    󰠅 Udacity Instructor 🐦 @aida_isay 🌐 cupsofcode.com
  2. Multiple User Actions sealed class FeedIntent { data class RestaurantClicked(val

    restaurantId: String) : FeedIntent() data class LikeClicked(val restaurantId: String, val isLiked: Boolean) : FeedIntent() } __
  3. Multiple Results val dataIntent = feedRestaurantsUseCase.execute() .map<FeedIntent> { FeedIntent.Data(restaurants =

    it.map { it.toUiModel(stringResources) }) } .startWith(FeedIntent.Loading) .onErrorReturn { FeedIntent.Error(error = it) } __
  4. Single ViewState data class FeedViewState( val isLoading: Boolean = false,

    val error: Throwable? = null, val restaurants: List<RestaurantUiModel> = emptyList(), val toolbarTitle: String = "", val searchedCity: String = "Hoboken", val emptyListMessage: String = "" ) __
  5. private val reducer = BiFunction<FeedViewState, FeedIntent, FeedViewState> { previous, intent

    -> when (intent) { is FeedIntent.Data -> { previous.copy( restaurants = intent.restaurants, isLoading = false, toolbarTitle = "Sample", emptyListMessage = "" ) } else -> previous } } __
  6. Resources: • Android MVI reactive architecture pattern • Unidirectional state

    flow patterns • Battle of the android architecture patterns