# MVVM

MVVM (Model-View-ViewModel) is a UI architectural design pattern that decouples UI and non-UI code using data binding.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## DTO -\> Domain -\> UI Model: When Is the Mapping Worth It?

DevFeed: [DTO -\> Domain -\> UI Model: When Is the Mapping Worth It?](<https://devfeed.tech/articles/dto-domain-ui-model-when-is-the-mapping-worth-it-100952.md>)

Original publisher: [Read original article](<https://proandroiddev.com/dto-domain-ui-model-mapping-clean-architecture-2603f0010fcf?source=rss----c72404660798---4>)

Author: Ravi Rawal

Published: 2026-10-26T13:38:18Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [modular-monolith](<https://devfeed.tech/topics/modular-monolith.md>), [adapter pattern](<https://devfeed.tech/topics/adapter-pattern.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>), [REST API](<https://devfeed.tech/topics/rest-api.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [clean-architecture](<https://devfeed.tech/tags/clean-architecture.md>), [coupling](<https://devfeed.tech/tags/coupling.md>), [domain](<https://devfeed.tech/tags/domain.md>), [external](<https://devfeed.tech/tags/external.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [maintenance](<https://devfeed.tech/tags/maintenance.md>), [mapping](<https://devfeed.tech/tags/mapping.md>), [model](<https://devfeed.tech/tags/model.md>), [models](<https://devfeed.tech/tags/models.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [software-development](<https://devfeed.tech/tags/software-development.md>), [software-engineering](<https://devfeed.tech/tags/software-engineering.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

DTO -> Domain -> UI mappings are useful when they protect distinct responsibilities, but three models are not required by default. The article's product example separates an API-shaped DTO from a domain Product that interprets fields such as price, seller type, and status, then from a ProductCardUiModel that adds formatted price, localized labels, and favorite state. Mapping can validate or reject incomplete records, represent unknown values, and keep backend changes from spreading into business logic or presentation. A ViewModel can combine product and favorite data into card models and expose screen loading, content, or error state separately; Composables render that state. Keep a boundary when the next layer has different needs, rules, or likely reasons to change. For a small feature with a stable API, simple UI, and no meaningful domain behavior, fewer models may avoid duplicated declarations and mapping omissions. Android guidance cited in the article allows separate models for complex apps and treats the domain layer as optional. Use simple explicit mappers where sufficient; extract dedicated ones when rules, reuse, or independent testing justify them.

### Source excerpt

Three models, two mapping steps, and one simple question: are we protecting architectural boundaries or just creating more code to maintain? Open a mobile application built with Clean Architecture, and you will probably find some variation of this flow: ProductDto -> Product -> ProductUiModel The API response becomes a DTO. The DTO becomes a domain model. The domain model becomes a UI model. Each transformation has its own mapper, and each model lives in its own package or module. It looks clean. It follows familiar architectural conventions. It can also produce a surprising amount of code for displaying a product on a screen. And that raises a question worth discussing: does every layer need its own model, or have we turned a useful architectural technique into a rule that we follow without questioning? I have seen both sides of this design make sense. Sharing a network DTO throughout an application can create coupling that becomes expensive later. Introducing multiple models that contain the same properties, however, can create maintenance work without delivering much protection. The interesting part is knowing the difference. Let's follow one feature -- a product listing -- from the API response to the screen and examine what each model should contribute, where the transformations belong, and when we can reasonably skip them. Start with the API contract Imagine a marketplace application that fetches a list of products from a backend. The response for each listing looks something like this: https://medium.com/media/02059b91befe4e6cc4715d4de56bc69b/href The networking layer needs a model capable of representing this response. In Kotlin, it might look like this: https://medium.com/media/7cea74b0c4f9a5ff5de917c0b67df314/href The nullable properties are intentional. They acknowledge that the response may contain missing values, even when the backend's ideal contract says otherwise. The DTO represents an external contract. Its field names, serialization annotations, and da

## The Power of stateIn in ViewModel

DevFeed: [The Power of stateIn in ViewModel](<https://devfeed.tech/articles/the-power-of-statein-in-viewmodel-88053.md>)

Original publisher: [Read original article](<https://proandroiddev.com/the-power-of-statein-in-viewmodel-6a57864a8c5d?source=rss----c72404660798---4>)

Author: chanzmao

Published: 2026-10-15T17:11:34Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [state-management](<https://devfeed.tech/topics/state-management.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [declarative-ui](<https://devfeed.tech/tags/declarative-ui.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [state-management](<https://devfeed.tech/tags/state-management.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

For UI state derived from observable data, the excerpt recommends expressing dependencies with Kotlin Flow operators such as `map` and `combine`, then using `stateIn` to expose the result as a `StateFlow`. Its examples derive a list screen's state from repository items and a mutable search query, avoiding manual copying and synchronization; `MutableStateFlow` remains appropriate for inputs such as the query. Explicit commands still fit one-time work, refreshes, and user actions. `SharingStarted.WhileSubscribed(5_000)` starts collection with a subscriber and stops it five seconds after the last unsubscribes, but does not itself guarantee a network request will repeat; `stateIn` shares and retains upstream emissions rather than fetching data.

### Source excerpt

Building Declarative UI State with Kotlin Flow. Image created by AI In Jetpack Compose, we often see ViewModels that manually manage UI state, call load() from init, and update several properties whenever data changes. This approach works, but it can introduce unnecessary boilerplate. As an application grows, keeping multiple pieces of state synchronized becomes increasingly difficult. Kotlin Flow offers a more declarative alternative. By combining Flow operators with stateIn, we can define how UI state is derived from its inputs and let the stream handle updates. The Hidden Cost of Manual State Updates Consider a typical ViewModel: class MyViewModel( private val repository: MyRepository ) : ViewModel() { private val _uiState = MutableStateFlow(UiState()) val uiState = _uiState.asStateFlow() init { load() } private fun load() { viewModelScope.launch { val items = repository.loadItems() _uiState.update { it.copy(items = items) } } } } This is a perfectly valid implementation. It is easy to understand, especially when loading data involves a one-time operation. However, the ViewModel is responsible for several things: Starting the initial load. Updating the state after loading. Preserving unrelated state fields. Keeping the UI state consistent as more inputs are added. As the screen becomes more complex, these responsibilities can lead to repetitive state-management code. What if the repository already exposes a Flow of items? Do we still need to collect it manually and copy every update into another state holder? Often, we do not. Do We Really Need to Call load()? A common Compose pattern is: LaunchedEffect(Unit) { viewModel.load() } Another option is to call load() from the ViewModel's init block. Both approaches have legitimate uses. A user-triggered refresh, a one-time operation, or a request that depends on a specific event may need an explicit command. But when the screen simply reflects data that is already represented by a Flow, manually initiating and synchro

## Sharing ViewModels Across Android and iOS in Kotlin Multiplatform Projects

DevFeed: [Sharing ViewModels Across Android and iOS in Kotlin Multiplatform Projects](<https://devfeed.tech/articles/is-androidx-viewmodel-the-best-choice-for-kmp-projects-gustavo-fao-valvassori-38251.md>)

Original publisher: [Read original article](<https://touchlab.co/kmp-view-models>)

Published: 2026-03-02T00:00:00Z

Content type: opinion

Language: en

Sources: [Touchlab](<https://devfeed.tech/sources/touchlab-enterprise-mobile-innovation-development.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Android](<https://devfeed.tech/topics/android.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [compose](<https://devfeed.tech/tags/compose.md>), [design-patterns](<https://devfeed.tech/tags/design-patterns.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kmp](<https://devfeed.tech/tags/kmp.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This article explains the MVVM pattern and examines how sharing ViewModels across Android and iOS affects developer experience in Kotlin Multiplatform projects. It discusses separation of concerns, binders, Compose, SKIE, and Android ViewModel lifecycle behavior, including configuration changes.

### Source excerpt

Sharing ViewModels between platforms affects the iOS developer experience. In this post we will discuss this topic and some possible solutions in KMP projects that respect the native feel of iOS and Android.

## Scalable API Response Handling Across Multi-Layered Architectures with Sandwich

DevFeed: [Scalable API Response Handling Across Multi-Layered Architectures with Sandwich](<https://devfeed.tech/articles/scalable-api-response-handling-across-multi-layered-architectures-with-sandwich-25924.md>)

Original publisher: [Read original article](<https://proandroiddev.com/scalable-api-response-handling-across-multi-layered-architectures-with-sandwich-39ab02ae8c90?source=rss-9bb203a4ab2e------2>)

Author: Jaewoong Eum

Published: 2026-02-08T06:25:14Z

Content type: article

Language: en

Sources: [Jaewoong Eum](<https://devfeed.tech/sources/stories-by-jaewoong-eum-on-medium.md>)

Topics: [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [API](<https://devfeed.tech/topics/api.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>)

Tags: [advanced](<https://devfeed.tech/tags/advanced.md>), [all](<https://devfeed.tech/tags/all.md>), [also](<https://devfeed.tech/tags/also.md>), [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [applications](<https://devfeed.tech/tags/applications.md>), [approach](<https://devfeed.tech/tags/approach.md>), [architectures](<https://devfeed.tech/tags/architectures.md>), [article](<https://devfeed.tech/tags/article.md>), [basic](<https://devfeed.tech/tags/basic.md>), [blocks](<https://devfeed.tech/tags/blocks.md>), [body](<https://devfeed.tech/tags/body.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [but](<https://devfeed.tech/tags/but.md>), [cases](<https://devfeed.tech/tags/cases.md>), [challenge](<https://devfeed.tech/tags/challenge.md>), [code](<https://devfeed.tech/tags/code.md>), [handling](<https://devfeed.tech/tags/handling.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [networking](<https://devfeed.tech/tags/networking.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>), [with](<https://devfeed.tech/tags/with.md>)

### AI overview

Sandwich preserves API outcome context across Android architecture layers by wrapping calls in a sealed `ApiResponse` with distinct success, HTTP error, and client exception cases. This avoids the ambiguity and repeated `try-catch` blocks that arise when data sources return fallback values such as empty lists. Retrofit integrates through `ApiResponseCallAdapterFactory`; Ktor uses `apiResponseOf`, and Ktorfit uses `ApiResponseConverterFactory`, yielding the same response type. The text describes handlers and transformations for mapping, sequential dependent requests, recovery, validation, filtering, and combining responses. `zip` returns the first failure if either response fails, while paginated `merge` can either fail on any page or retain successful pages and ignore failures. Flow and suspend variants support asynchronous work in handlers. The overview is based on the supplied article text.

### Source excerpt

Unsplash@picoftasty Modern Android applications commonly adopt multi-layered architectures such as MVVM or MVI, where data flows through distinct layers: a data source, a repository, and a ViewModel (or presentation layer). Each layer has a specific responsibility, and network responses must propagate through all of them before reaching the UI. While this separation produces clean, testable code, it introduces a real challenge: how do you handle API responses, including errors and exceptions, as they cross each layer boundary? Most developers solve this by wrapping API calls in try-catch blocks and returning fallback values. This works for small projects, but as the number of API calls grows, the approach creates ambiguous results, scattered boilerplate, and lost context that downstream layers need. You end up with ViewModels that cannot tell whether an empty list means "no data" or "network failure," repositories that swallow important error details, and data sources that repeat the same error handling pattern dozens of times. In this article, you'll explore the problems that emerge when handling Retrofit API calls across layered architectures, why conventional approaches break down at scale, and how Sandwich provides a type safe, composable solution that simplifies response handling from the network layer all the way to the UI. You'll also walk through the full set of Sandwich APIs, from basic response handling to advanced patterns like sequential composition, response merging, global error mapping, and Flow integration, each with real world use cases that show when and why you would reach for them. Retrofit API calls with coroutines Most Android projects use Retrofit with Kotlin coroutines for network communication. A typical service interface looks like this: https://medium.com/media/ebcba33386d664d1cf69a89234d2e22a/href The service returns a List<Poster> directly. Retrofit deserializes the JSON response body and gives you the data. This works perfectly when the

## Behind the Global Launch: Decoding the Android Engineering Strategy for Our New App

DevFeed: [Behind the Global Launch: Decoding the Android Engineering Strategy for Our New App](<https://devfeed.tech/articles/behind-the-global-launch-decoding-the-android-engineering-strategy-for-our-new-app-56785.md>)

Original publisher: [Read original article](<https://engineering.mercari.com/en/blog/entry/20251120-behind-the-global-launch-decoding-the-android-engineering-strategy-for-our-new-app/>)

Author: Karthi

Published: 2025-11-20T14:21:32Z

Content type: article

Language: en

Sources: [Mercari Engineering](<https://devfeed.tech/sources/mercari-engineering.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [CI/CD](<https://devfeed.tech/topics/cicd.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Flutter](<https://devfeed.tech/topics/flutter.md>), [React Native](<https://devfeed.tech/topics/react-native.md>), [cross-platform](<https://devfeed.tech/topics/cross-platform.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-engineer](<https://devfeed.tech/tags/android-engineer.md>), [app-development](<https://devfeed.tech/tags/app-development.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [ci-cd](<https://devfeed.tech/tags/ci-cd.md>), [code](<https://devfeed.tech/tags/code.md>), [compose](<https://devfeed.tech/tags/compose.md>), [cross-platform](<https://devfeed.tech/tags/cross-platform.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [flutter](<https://devfeed.tech/tags/flutter.md>), [hybrid](<https://devfeed.tech/tags/hybrid.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>)

### AI overview

An Android engineer at Mercari explains the strategy behind developing a new global app. The team chose native Android development to reuse existing libraries, infrastructure, CI/CD, and organizational knowledge, while weighing the trade-offs against React Native and Flutter.

### Source excerpt

Hello! I'm Karthi, an Android engineer on the Cross Border (XB) Client Core team responsible for building foundational code for Mercari's global apps.This article is part of the series discussing how we developed a new global service and covers android engineering strategy for global app development. Building a product for a worldwide audience takes careful [...]

## Android ViewModel Data Loading: Best Practices and Flow-Based Architecture

DevFeed: [Android ViewModel Data Loading: Best Practices and Flow-Based Architecture](<https://devfeed.tech/articles/android-viewmodel-data-loading-best-practices-and-flow-based-architecture-22967.md>)

Original publisher: [Read original article](<https://funkymuse.github.io/posts/properly-load-data/>)

Author: FunkyMuse

Published: 2025-08-28T23:11:00Z

Content type: opinion

Language: en

Sources: [FunkyMuse](<https://devfeed.tech/sources/funkymuse.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [antipatterns](<https://devfeed.tech/tags/antipatterns.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [data](<https://devfeed.tech/tags/data.md>), [flow](<https://devfeed.tech/tags/flow.md>), [loading](<https://devfeed.tech/tags/loading.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

The article argues that loading data in a ViewModel's `init {}` block can cause stale data on backstack returns, dispatcher timing races with Compose, and harder tests. It proposes turning cold flows into hot `StateFlow`s with sharing strategies, refresh triggers, `distinctUntilChanged()`, and optional cached state to control when data reloads. A five-second timeout is offered as an example for retaining data across brief configuration changes while refreshing when collectors return later; the author also suggests adjusting it for real-time needs. Reusable ViewModel abstractions can reduce boilerplate, though the described extension pattern does not cover complex flow chaining. The author presents this as an opinionated approach for many common cases, with tradeoffs such as added state mapping complexity, and notes that it may not fit every application.

### Source excerpt

Architecture discussions in Android development often spark passionate debates--sometimes garnering both praise and criticism. Writing about these topics isn't easy, but that's what makes it worthwhile. This article presents my opinionated perspective on data loading patterns, refined through experience and recovery from recent surgeries (one recovery is still in progress). Consider this a sna...

## What Every Android Developer Should Have in Their GitHub?

DevFeed: [What Every Android Developer Should Have in Their GitHub?](<https://devfeed.tech/articles/what-every-android-developer-should-have-in-their-github-25844.md>)

Original publisher: [Read original article](<https://blog.stackademic.com/what-every-android-developer-should-have-in-their-github-de8deab051b9?source=rss-8aced922ece------2>)

Author: Ban Markovic

Published: 2024-02-05T11:00:04Z

Content type: article

Language: en

Sources: [Ban Markovic](<https://devfeed.tech/sources/stories-by-ban-markovic-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [GitHub](<https://devfeed.tech/topics/github.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [dagger-hilt](<https://devfeed.tech/topics/dagger-hilt.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>), [REST API](<https://devfeed.tech/topics/rest-api.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [asynchronous-communication](<https://devfeed.tech/tags/asynchronous-communication.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [fetching](<https://devfeed.tech/tags/fetching.md>), [github](<https://devfeed.tech/tags/github.md>), [hilt](<https://devfeed.tech/tags/hilt.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [koin](<https://devfeed.tech/tags/koin.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [portfolio](<https://devfeed.tech/tags/portfolio.md>), [rest-api](<https://devfeed.tech/tags/rest-api.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>)

### AI overview

The article recommends a compact Android GitHub showcase with two screens: fetch a list from a REST API, display it, and let users open an item's details. It advises demonstrating either MVI or MVVM, organizing files by feature or type, handling asynchronous work with a library such as Kotlin Coroutines, LiveData, or RxJava, and using dependency injection with Hilt, Dagger, or Koin. It also recommends unit tests for ViewModel, UseCase, and Repository classes. The article presents these as ways to show core Android development skills to potential employers; it does not compare the listed architecture or library options.

### Source excerpt

In the competitive world of Android development, having a strong GitHub portfolio is crucial for showcasing your skills to potential employers. One effective way to demonstrate your expertise is by creating a concise yet comprehensive project that highlights key aspects of Android development. In this article, we'll explore the essential components that every Android developer should have in their GitHub, focusing on a project that encapsulates fundamental skills. The Project Overview A successful showcase project should include two screens and cover the following key functionalities: Fetching and Displaying Data - Utilize a REST API to fetch a list of items. - Display this list on the first screen of the app. Navigation and Detailed Information - Enable users to navigate to a second screen by clicking on a specific item. - On the second screen, display more detailed information about the selected item. Key Considerations for the Showcase ProjectArchitecture -- MVI or MVVM Clearly implement and showcase your understanding of the chosen architecture (MVI or MVVM). Organize code files in a logical and easily understandable structure. File Organization Demonstrate a well-organized project structure, separating concerns and making codebase easily maintainable (feature-based or type-based folders structure). Asynchronous Communication Showcase your proficiency in handling asynchronous tasks by using an appropriate library (e.g., Kotlin Coroutines, LiveData, RxJava). Unit Tests Impress potential employers by including unit tests to validate the functionality of critical components (cover your ViewModel, UseCase, Repository classes with unit tests). Dependency Injection (DI): Implement and demonstrate your use of dependency injection for managing component dependencies (Hilt, Dagger, Koin). Why This Project Matters This concise project effectively showcases your abilities in: Displaying a list of items Fetching data from the internet Implementing navigation between screens

## ViewModel: for UI business, not UI operations 😮

DevFeed: [ViewModel: for UI business, not UI operations 😮](<https://devfeed.tech/articles/viewmodel-for-ui-business-not-ui-operations-25758.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/viewmodel-for-ui-business-not-ui-operations/>)

Author: Shreyas Patil

Published: 2022-12-19T12:30:42Z

Content type: opinion

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [bottom-sheet](<https://devfeed.tech/tags/bottom-sheet.md>), [business](<https://devfeed.tech/tags/business.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [business-operations](<https://devfeed.tech/tags/business-operations.md>), [dialog](<https://devfeed.tech/tags/dialog.md>), [discussion](<https://devfeed.tech/tags/discussion.md>), [error](<https://devfeed.tech/tags/error.md>), [examples](<https://devfeed.tech/tags/examples.md>), [know](<https://devfeed.tech/tags/know.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [logging](<https://devfeed.tech/tags/logging.md>), [message](<https://devfeed.tech/tags/message.md>), [model](<https://devfeed.tech/tags/model.md>), [models](<https://devfeed.tech/tags/models.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [operational](<https://devfeed.tech/tags/operational.md>), [state-management](<https://devfeed.tech/tags/state-management.md>), [ui](<https://devfeed.tech/tags/ui.md>), [ux](<https://devfeed.tech/tags/ux.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

The author argues that Android ViewModels should hold UI state and execute UI-related business logic, while leaving UI operations and component interactions to the UI. For API failures, the ViewModel should report the business failure without encoding a toast-specific state, so the UI can choose how to present it (for example, as a toast, dialog, or snackbar) without changing the ViewModel. The excerpt also criticizes storing bottom-sheet expand/collapse interaction state in a ViewModel, but cuts off before giving the proposed alternative.

### Source excerpt

Stop misusing ViewModels! Learn why ViewModels should handle UI business logic, not UI operations like showing toasts or navigation.

## How to use Kotlin Multiplatform ViewModel in SwiftUI and Jetpack Compose

DevFeed: [How to use Kotlin Multiplatform ViewModel in SwiftUI and Jetpack Compose](<https://devfeed.tech/articles/how-to-use-kotlin-multiplatform-viewmodel-in-swiftui-and-jetpack-compose-23905.md>)

Original publisher: [Read original article](<https://medium.com/icerock/how-to-use-kotlin-multiplatform-viewmodel-in-swiftui-and-jetpack-compose-8158e98c091d?source=rss----b74ae24564e---4>)

Author: Aleksey Mikhailov

Published: 2022-04-30T12:34:48Z

Content type: tutorial

Language: en

Sources: [IceRock Development](<https://devfeed.tech/sources/icerock-development-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [SwiftUI](<https://devfeed.tech/topics/swiftui.md>)

Tags: [compose](<https://devfeed.tech/tags/compose.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [swift](<https://devfeed.tech/tags/swift.md>), [swiftui](<https://devfeed.tech/tags/swiftui.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

MOKO MVVM 0.13.0 lets a Kotlin Multiplatform ViewModel drive both Jetpack Compose and SwiftUI. The example moves login and password state, loading status, button enablement, and a one-time success action into common code using StateFlow and a Channel. On Android, Compose collects the flows and observes actions with moko-mvvm helpers; lifecycle-viewmodel-compose supplies a ViewModel retained across screen rotation. On iOS, CocoaPods adds mokoMvvmFlowSwiftUI, and CMutableStateFlow, CStateFlow, and CFlow preserve generic types for Swift. Its binding and state helpers connect SwiftUI controls, while createPublisher exposes actions through Combine. The article also uses moko-kswift to generate an enum from the sealed action interface for exhaustive Swift handling. The walkthrough specifies Kotlin 1.6.10 for Compose 1.1.1 compatibility and uses CocoaPods integration for the project.

### Source excerpt

We at IceRock Development have been using the MVVM approach for many years, and the last 4 years our ViewModel are shared in the common code. We do it by using our library moko-mvvm. In the last year, we have been actively moving to using Jetpack Compose and SwiftUI to build UI in our projects. And it require MOKO MVVM improvements to make it more comfortable for developers on both platforms to work with this approach. On April 30, 2022, new version of MOKO MVVM -- 0.13.0 was released. This version has full support for Jetpack Compose and SwiftUI. Let's take an example of how you can use ViewModel from common code with these frameworks. The example will be simple -- an application with an authorization screen. Two input fields -- login and password, button Log in and a message about a successful login after a second of waiting (while waiting, we turn the progress bar). Create a project The first step is simple -- take Android Studio, install Kotlin Multiplatform Mobile IDE plugin, if not already installed. Create a project according to the template "Kotlin Multiplatform App" using CocoaPods integration (it's more convenient with them, plus we need it to connect an additional CocoaPod later). git commit Login screen on Android with Jetpack Compose The app template uses the standard Android View approach, so we need to enable Jetpack Compose before implementation of UI. Enable Compose support in androidApp/build.gradle.kts: val composeVersion = "1.1.1"android { // ... buildFeatures { compose=true } composeOptions { kotlinCompilerExtensionVersion = composeVersion } } And we add the dependencies we need, removing the old unnecessary ones (related to the usual approach with view): dependencies { implementation(project(":shared")) implementation("androidx.compose.foundation:foundation:$composeVersion") implementation("androidx.compose.runtime:runtime:$composeVersion") // UI implementation("androidx.compose.ui:ui:$composeVersion") implementation("androidx.compose.ui:ui-tooling

## 🙅♂ Don't let ViewModel know about framework level dependencies

DevFeed: [🙅♂ Don't let ViewModel know about framework level dependencies](<https://devfeed.tech/articles/don-t-let-viewmodel-know-about-framework-level-dependencies-25714.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/dont-let-viewmodel-knew-about-framework-level-dependencies/>)

Author: Shreyas Patil

Published: 2021-09-17T12:18:27Z

Content type: article

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-framework](<https://devfeed.tech/tags/android-framework.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [context](<https://devfeed.tech/tags/context.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [framework](<https://devfeed.tech/tags/framework.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [leaks](<https://devfeed.tech/tags/leaks.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [maintainability](<https://devfeed.tech/tags/maintainability.md>), [memory](<https://devfeed.tech/tags/memory.md>), [memory-leaks](<https://devfeed.tech/tags/memory-leaks.md>), [practices](<https://devfeed.tech/tags/practices.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [testing](<https://devfeed.tech/tags/testing.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

The excerpt recommends keeping Android framework references such as Activity, Context, View, and Drawable out of ViewModels. A retained reference can outlive its owner and risk a memory leak; framework dependencies also make ViewModels harder to test, modularize, and maintain. It notes that AndroidViewModel exposes Application context and says this breaks the recommendation, but the excerpt ends while discussing testing, so it does not provide the article's full argument or concrete alternatives.

### Source excerpt

Explore best practices for Android ViewModels. Learn why keeping framework references out of ViewModels is crucial for testing and preventing memory leaks.

## Why Workflow?

DevFeed: [Why Workflow?](<https://devfeed.tech/articles/why-workflow-15962.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/why-workflow>)

Author: Stephen Edwards

Published: 2021-08-19T21:00:00Z

Content type: opinion

Language: en

Sources: [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [Library](<https://devfeed.tech/topics/library.md>), [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [ui-testing](<https://devfeed.tech/topics/ui-testing.md>)

Tags: [2](<https://devfeed.tech/tags/2.md>), [about](<https://devfeed.tech/tags/about.md>), [actions](<https://devfeed.tech/tags/actions.md>), [addition](<https://devfeed.tech/tags/addition.md>), [adoption](<https://devfeed.tech/tags/adoption.md>), [all](<https://devfeed.tech/tags/all.md>), [also](<https://devfeed.tech/tags/also.md>), [android](<https://devfeed.tech/tags/android.md>), [application](<https://devfeed.tech/tags/application.md>), [applications](<https://devfeed.tech/tags/applications.md>), [approach](<https://devfeed.tech/tags/approach.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [area](<https://devfeed.tech/tags/area.md>), [based](<https://devfeed.tech/tags/based.md>), [best](<https://devfeed.tech/tags/best.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [framework](<https://devfeed.tech/tags/framework.md>), [make](<https://devfeed.tech/tags/make.md>), [square](<https://devfeed.tech/tags/square.md>), [workflow](<https://devfeed.tech/tags/workflow.md>)

### AI overview

Workflow structures mobile features as composable components with finite states, explicit contracts, and immutable state transitions managed by a runtime event loop. The article argues this makes logic easier to instrument, test, and debug at scale, while reducing coupling between features and clarifying team communication. Workflows declare the rendering, child workflows, and side effects for each state; the runtime handles how children and effects start and stop. This supports reactive, declarative programming and fits Square's MVVM approach, where a Workflow tree produces a ViewModel for binding to a native UI. The explicit state and contract definitions add work even for a simple feature, but the article presents them as a foundation for reuse, safer changes, and easier adoption of Compose and SwiftUI. It also notes alignment with Kotlin coroutine structured concurrency.

### Source excerpt

Or why does Square make its own application framework?

## Modelling UI State on Android

DevFeed: [Modelling UI State on Android](<https://devfeed.tech/articles/modelling-ui-state-on-android-25873.md>)

Original publisher: [Read original article](<http://lordraydenmk.github.io//2021/modelling-ui-state/>)

Author: Stojan Anastasov

Published: 2021-01-29T00:00:00Z

Content type: article

Language: en

Sources: [Stojan Anastasov's blog](<https://devfeed.tech/sources/stojan-anastasov-s-blog.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [data type](<https://devfeed.tech/topics/data-type.md>), [Android](<https://devfeed.tech/topics/android.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [software-development](<https://devfeed.tech/topics/software-development.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [cardinality](<https://devfeed.tech/tags/cardinality.md>), [fp](<https://devfeed.tech/tags/fp.md>), [functional](<https://devfeed.tech/tags/functional.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [modelling](<https://devfeed.tech/tags/modelling.md>), [state](<https://devfeed.tech/tags/state.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

The article recommends modeling Android UI state so the type permits exactly the states the UI can validly show. It treats types as sets: properties in product types multiply possible values, while sealed class cases add them. For a traffic light, a data class or separate observable Boolean and nullable color properties allow 16 combinations, including contradictory states. A sealed `TrafficLightState` with `Loading`, `Error`, and `Success(color)` has five possible values, matching the described UI states and making invalid combinations unrepresentable. The article presents enums as a precise fit for a fixed set such as red, yellow, and green, contrasting them with strings or Boolean-property data classes that also admit invalid values. It frames these choices as tradeoffs in data modeling, with fewer invalid states intended to simplify code and reduce validity checks and tests.

### Source excerpt

The recommended approach from Google for Android development is holding the UI state in a ViewModel and having the View observe it. To achieve that one can use LiveData, StateFlow, RxJava or a similar tool. But how to model the UI state? Use a data class or a sealed class? Use one observable property or many? I will describe the tradeoffs between the approaches and present a tool to help you decide which one to use. This article is heavily inspired by Types as Sets from the Elm guide, a large part is a translation from Elm to Kotlin. Photo by Marc-Olivier Jodoin on Unsplash Types as sets By Making Data Structure we can make sure the possible values in code exactly match the valid values in real life. Doing that helps to avoid a whole class of bugs related to invalid data. To achieve that, first we need to understand the relationship between Types and Sets. We can think of Types as sets of values, they contain unique elements and there is no ordering between them. For example: Nothing - the empty set, it contains no elements Unit - the singleton set, it contains one element - Unit Boolean - contains the elements true and false Int - contains the elements: ... -2, -1, 0, 1, 2 ... Float - contains the elements: 0.1, 0.01, 1.0 .... String - contains the elements: "", "a", "b", "Kotlin", "Android", "Hello world!"... So when you write: val x: Boolean it means x belongs to the set of Boolean values and can be either true or false. Cardinality In Mathematics, Cardinality is the measure of "number of elements" of a Set. For example the set of Boolean contains the elements [true, false] so it has a cardinality = 2. Let's take a look at the cardinality of the sets mentioned above: Nothing - 0 Unit - 1 Boolean - 2 Short - 65535 Int - ∞ Float - ∞ String- ∞ Note: The cardinality of Int and Float is not exactly infinity, it's 2^32 however that is a huge number. When building apps, we use built-in types and create custom types using constructs like data classes and sealed classes. Product

## Fragments, ViewBinding and memory leaks

DevFeed: [Fragments, ViewBinding and memory leaks](<https://devfeed.tech/articles/fragments-viewbinding-and-memory-leaks-25871.md>)

Original publisher: [Read original article](<http://lordraydenmk.github.io//2020/view-binding/>)

Author: Stojan Anastasov

Published: 2020-10-30T00:00:00Z

Content type: article

Language: en

Sources: [Stojan Anastasov's blog](<https://devfeed.tech/sources/stojan-anastasov-s-blog.md>)

Topics: [Memory Leaks](<https://devfeed.tech/topics/memory-leaks.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-android](<https://devfeed.tech/tags/kotlin-android.md>), [kotlin-android-extensions](<https://devfeed.tech/tags/kotlin-android-extensions.md>), [leaks](<https://devfeed.tech/tags/leaks.md>), [memory](<https://devfeed.tech/tags/memory.md>), [memory-leak](<https://devfeed.tech/tags/memory-leak.md>), [memory-leaks](<https://devfeed.tech/tags/memory-leaks.md>), [view-binding](<https://devfeed.tech/tags/view-binding.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>), [xml](<https://devfeed.tech/tags/xml.md>)

### AI overview

ViewBinding itself does not inherently cause Fragment memory leaks; the risk comes from a longer-lived Fragment retaining a binding to its shorter-lived view. The conventional pattern stores a nullable binding and clears it in onDestroyView, but forgetting that cleanup leaks the view and is error-prone. The article proposes binding the view locally in onViewCreated instead, so the reference has a shorter scope and needs no manual clearing; this assumes an MVVM-style UI. ViewBinding requires references such as binding.textView where Kotlin Android Extensions allowed textView directly. Kotlin's with(binding) can reduce that repetition.

### Source excerpt

As an Android engineer one of the basic things you need to do is bind the views (written in XML) with Kotlin/Java code. You can do this with the basic primitive -findViewById(), using a library like ButterKnife, using a compiler plugin like Kotlin Android Extensions or starting with Android Studio/AGP 3.6 ViewBinding. There are a few other options out there but in my experience these are the most common. The Kotlin Android Extensions plugin will be deprecated (except the @Parcelize functionality) in favor of ViewBinding soon. I see this as a positive change, but not everyone shares my opinion. One of the common arguments against ViewBinding (according to a comment in the ticket, a discussion on reddit and a friend of mine) is: ViewBinding introduces memory leaks in Fragments. Let's take a look into the usage example from the official docs: private var _binding: ResultProfileBinding? = null // This property is only valid between onCreateView and // onDestroyView. private val binding get() = _binding!! override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { _binding = ResultProfileBinding.inflate(inflater, container, false) val view = binding.root return view } override fun onDestroyView() { super.onDestroyView() _binding = null } The fragment outlives the view, which means that if we forget to clear the binding reference in onDestroyView this will cause a memory leak. Now I do agree that this is error prone, you have to remember to clear the binding reference in each fragment you create. However this problem is not inherent to ViewBinding, but to this kind of usage. The problem here is: a component with a larger scope (the fragment) keeps a reference to a component with a smaller scope (the binding). Clearing the reference is a workaround, the proper solution is to move the reference to the correct scope: private val viewModel by viewModels<ProfileViewModel>() override fun onViewCreated(view: View, savedInsta

## ViewModel. How it works.

DevFeed: [ViewModel. How it works.](<https://devfeed.tech/articles/viewmodel-how-it-works-26015.md>)

Original publisher: [Read original article](<https://unbreakable-titan.medium.com/viewmodel-how-it-works-434282649286?source=rss-e32583ce94d4------2>)

Author: Vladislav Puryev

Published: 2020-01-18T15:40:09Z

Content type: article

Language: en

Sources: [Vladislav Puryev](<https://devfeed.tech/sources/stories-by-vladislav-puryev-on-medium.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-framework](<https://devfeed.tech/tags/android-framework.md>), [code](<https://devfeed.tech/tags/code.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [data](<https://devfeed.tech/tags/data.md>), [evolution](<https://devfeed.tech/tags/evolution.md>), [helps](<https://devfeed.tech/tags/helps.md>), [save](<https://devfeed.tech/tags/save.md>), [state](<https://devfeed.tech/tags/state.md>), [version](<https://devfeed.tech/tags/version.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

The excerpt traces how Android ViewModel instances survive configuration changes across framework versions. In 2017, ViewModelProvider retrieves instances from a ViewModelStore held by a retained HolderFragment. In 2018, activities retain the store through non-configuration instance callbacks, while FragmentManager saves fragment stores in FragmentManagerNonConfig and restores them into recreated fragments. In 2019, fragment stores are managed through a FragmentManagerViewModel obtained from the activity's store. The article emphasizes that ViewModel itself contains no saving mechanism; retention comes from framework plumbing. It warns against overriding Activity.getLastNonConfigurationInstance(), which may break ViewModel retention or cause exceptions. Code is described as shortened, with full implementations available in framework sources.

### Source excerpt

Android ViewModel. How it works. Hello everybody. This post will be about popular solution from Google for Android developers -- ViewModel (if you are not familiar with it yet -- get started from official documentation). The main goal of article -- show you how viewModel works, how this tool helps us to save state of our screens. First of all it is better to note that viewModel -- is just java code inside Android framework and there is no any magic... almost. This mechanism was improved something about three times from its origin (2017) till the present day. Let's take a look at "Evolution of anatomy". WARNING! This article contains a lot of technical content and internals of Android framework. And please pay attention -- all demonstrated code you can find in your Android Framework using middle-click or ctrl + left-click. There is no any of self-made code -- all is inside Android framework. Attention again -- most of code will be provided in shortened form. Only necessary details. Full versions you can find in Android Framework source codes straight inside your IDE. ViewModel 2017 Honestly, this part (I mean exactly ViewModel's version of 2017) can be unnecessary, because Medium has several articles, that describes viewModel saving state mechanism in first version. I like this one. But I suggest you more code than there. First of all let's take a look at ViewModel class itself. According to official documentation: The ViewModel class allows data to survive configuration changes such as screen rotations. It can lead to research this class. https://medium.com/media/3966f6a014283670bd0d0430100902cd/href It is just simple abstract class. Without any secrets. With one empty method. Can documentation be wrong (or obsolete) so long time? This question is not so obvious. From one side, if you will create your child viewModel and initialize it using constructor, in this case saving states mechanism will not work. But if you are doing everything in the right way (using special initial

## Build complex screens faster on Android with Epoxy

DevFeed: [Build complex screens faster on Android with Epoxy](<https://devfeed.tech/articles/build-complex-screens-faster-on-android-with-epoxy-24563.md>)

Original publisher: [Read original article](<https://medium.com/bleeding-edge/build-complex-screens-faster-on-android-1773c5a64352?source=rss----d8ebe85cdc0f---4>)

Author: Akshay Chordiya

Published: 2019-12-30T13:31:50Z

Content type: article

Language: en

Sources: [Bleeding Edge - Medium](<https://devfeed.tech/sources/bleeding-edge-medium.md>)

Topics: [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [mobile-app-performance](<https://devfeed.tech/topics/mobile-app-performance.md>)

Tags: [adapter](<https://devfeed.tech/tags/adapter.md>), [airbnb](<https://devfeed.tech/tags/airbnb.md>), [all](<https://devfeed.tech/tags/all.md>), [android](<https://devfeed.tech/tags/android.md>), [approach](<https://devfeed.tech/tags/approach.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [article](<https://devfeed.tech/tags/article.md>), [awesome](<https://devfeed.tech/tags/awesome.md>), [based](<https://devfeed.tech/tags/based.md>), [basics](<https://devfeed.tech/tags/basics.md>), [beautiful](<https://devfeed.tech/tags/beautiful.md>), [build](<https://devfeed.tech/tags/build.md>), [but](<https://devfeed.tech/tags/but.md>), [can](<https://devfeed.tech/tags/can.md>), [complex](<https://devfeed.tech/tags/complex.md>), [component](<https://devfeed.tech/tags/component.md>), [controller](<https://devfeed.tech/tags/controller.md>), [epoxy](<https://devfeed.tech/tags/epoxy.md>), [faster](<https://devfeed.tech/tags/faster.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [recyclerview](<https://devfeed.tech/tags/recyclerview.md>), [ui](<https://devfeed.tech/tags/ui.md>), [with](<https://devfeed.tech/tags/with.md>)

### AI overview

Epoxy lets Android teams compose complex RecyclerView screens from separate models, each tied to a view type and layout. A controller declares the ordered models; data flows through the models to views, while callbacks update state. At Clue, this modularity made view types easier to reuse, develop in parallel, and change as the UI evolved. Epoxy also offers a Kotlin DSL, optional background diffing, and defaults such as LinearLayoutManager. The article says performance should be comparable to plain RecyclerView when its usage rules are followed, and advises configuring model validation for production. Tradeoffs include a learning curve and fewer community resources than RecyclerView, so the author recommends evaluating it in a sample project.

### Source excerpt

Rowing the boat -- Illustration by Marta PucciBuild complex screens faster on Android⚡ -- Our journey with Epoxy RecyclerView is such an important UI component on Android. But using it can get complex and error prone--especially when dealing with different view types and pagination. Moreover, it's hard when working on the same screen within the team. In this article, I'm going to share basics of Epoxy and an overview of the problems it helped us solve. Here's our journey of how we adopted Epoxy at Clue to build our UIs faster in parallel within the team.⚡ Backstory It all started with our users, who wanted a more understandable and interactive view of their historical tracking data. ✨(For Clue users, this is generally their menstrual cycles & symptoms.) So our awesome design team came up with this beautiful intuitive design 😍: Enhanced Analysis screen in Clue app I know what you're thinking already: that's a lot of view types. And we were definitely concerned about the performance and responsiveness of the screen. That's when we decided to see if we could use any third-party library to help us with our goal. Epoxy Epoxy is a library from Airbnb which takes a declarative / composable approach to build the UI--typically, a list. It uses RecyclerView under the hood It simplifies creation of static and dynamic layouts Each item in the list is associated to an epoxy model which defines the item's layout and manages binding the data and releasing the view's resources when it's recycled. Item <-> Epoxy Model <-> Layout resource The order of the items shown on the UI is based on how you add the model to the adapter or controller. Philosophy Epoxy encourages a usage pattern similar to the popular MVVM and MVI architecture where the data flows in one direction (UDF - uni-directional data flow). Flow with Epoxy The data forms the state of the UI then goes to EpoxyModel and to the views on the RecyclerView . The Epoxy Model behaves like a ViewModel and provides the interface betwe

## Remind iOS: Present All the Things!

DevFeed: [Remind iOS: Present All the Things!](<https://devfeed.tech/articles/remind-ios-present-all-the-things-31930.md>)

Original publisher: [Read original article](<http://engineering.remind.com/ios-presentation/>)

Author: Remind

Published: 2019-05-28T00:00:00Z

Content type: article

Language: en

Sources: [Remind](<https://devfeed.tech/sources/remind.md>)

Topics: [User interface design](<https://devfeed.tech/topics/ui-design.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [Design system](<https://devfeed.tech/topics/design-system.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>)

Tags: [ios](<https://devfeed.tech/tags/ios.md>), [layout](<https://devfeed.tech/tags/layout.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [subclass](<https://devfeed.tech/tags/subclass.md>)

### AI overview

The excerpt describes Remind's MVVM-oriented iOS practices for building reusable UI components. The team uses programmatic layout with SnapKit, citing easier code review and parallel work as reasons for leaving xibs, while acknowledging teams may choose differently. It recommends encapsulating related controls in UIView subclasses, keeping internal primitives private, and exposing data through a present(...) method or limited properties. View models adapt domain objects into presentation data, while closures with action enums report user actions. Reusable design components get their own files; feature-specific views stay private alongside their view controller. The author also recommends separating UI management from navigation sequence so view controllers handle fewer responsibilities.

### Source excerpt

For the past couple years we've been implementing new features with an MVVM-driven approach. Over that time, we've settled into a couple of good (I think) patterns for implementing UIView subclasses, composing them in various view hierarchies, and handling the interactions between them. Ultimately, the goal of any iOS application is to get data presented onto the screen, so I thought I'd share what's been working well for us in that department. Layout In Code It's a debate where every team eventually has to pick a side: Do we use storyboards and xibs, or do we write all of our layout in code? To make a long story short, our team started with Interface Builder, but we abandoned xibs a few years ago and have gone to fully programmatic layout code using SnapKit as our DSL of choice. Every team's needs will be different, but we think it's important that we can effectively code-review each other's layout implementations and potentially have multiple people working on the same screen, neither of which are really practical with xibs. I'll leave it at that -- you do you. Use UIView Subclasses Liberally Nothing clutters the actual logic of a UIViewController like big blocks of view construction code. Whenever you have a logical grouping UI primitives (UILabel, UIImageView, UIButton, etc), make a UIView subclass that encapsulates all of the relative layout inside that view container. This allows you to build the view hierarchy for your view controller in simpler, larger, more logical chunks of UI. One of the more complex UI layouts we have in our application is the settings screen for a class the user owns. Let's look at the layout and focus on the CLASS SETTINGS section, which contains two items, each consisting of two labels and a switch. On our first iteration, our view controller maintained property accessors for each of those primitives: class ClassSettingsViewController: UIViewController { ... private let isPublicTitleLabel = UILabel() private let isPublicMessageLabel =

## Reportoire, the journey to data source independency

DevFeed: [Reportoire, the journey to data source independency](<https://devfeed.tech/articles/reportoire-the-journey-to-data-source-independency-28080.md>)

Original publisher: [Read original article](<https://tech.trivago.com/post/repo-pattern-article/>)

Author: Rafael Ortega Lupión Follow

Published: 2017-01-30T00:00:00Z

Content type: article

Language: en

Sources: [Trivago](<https://devfeed.tech/sources/trivago.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [software-architecture](<https://devfeed.tech/topics/software-architecture.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [mvc](<https://devfeed.tech/topics/mvc.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [app](<https://devfeed.tech/tags/app.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [concepts](<https://devfeed.tech/tags/concepts.md>), [coverage](<https://devfeed.tech/tags/coverage.md>), [data](<https://devfeed.tech/tags/data.md>), [decision-making](<https://devfeed.tech/tags/decision-making.md>), [decoupling](<https://devfeed.tech/tags/decoupling.md>), [dependency](<https://devfeed.tech/tags/dependency.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [developers](<https://devfeed.tech/tags/developers.md>), [logic](<https://devfeed.tech/tags/logic.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [model](<https://devfeed.tech/tags/model.md>), [models](<https://devfeed.tech/tags/models.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [source](<https://devfeed.tech/tags/source.md>), [test](<https://devfeed.tech/tags/test.md>), [test-coverage](<https://devfeed.tech/tags/test-coverage.md>), [testing](<https://devfeed.tech/tags/testing.md>), [view](<https://devfeed.tech/tags/view.md>)

### AI overview

Reportoire separates data access from Android view models through repositories, which choose among data sources and may store retrieved data. The excerpt's `MemoryNetworkRepository` checks memory first, then fetches from the network using `CachedObservableSource` and `MemoryCacheSource`. Developers extend `CachedObservableSource` to define API calls and map results into success or error values. View models obtain repositories through the app's dependency management; the example mentions a custom configurator or Dagger's `@Inject`. This keeps source selection and data handling out of view models, which the excerpt says can otherwise grow difficult to scale and test.

### Source excerpt

Concepts like separation of concerns, logic decoupling or dependency injection are things we developers have heard more than a couple of times. At trivago, the Android app is developed using the Model View ViewModel (MVVM) architecture, aiming for views as dumb as possible, leaving the decision making to the view models. This leads to an increased test coverage since testing logic in views is something we can't do that easily.

## Sharing Android Business Logic with iOS Using Doppl and MVP Architecture

DevFeed: [Sharing Android Business Logic with iOS Using Doppl and MVP Architecture](<https://devfeed.tech/articles/mvp-for-ios-and-and-pdq-kevin-galligan-38301.md>)

Original publisher: [Read original article](<https://touchlab.co/mvp-for-ios-and-and-pdq>)

Published: 2016-12-12T17:00:07Z

Content type: article

Language: en

Sources: [Touchlab](<https://devfeed.tech/sources/touchlab-enterprise-mobile-innovation-development.md>)

Topics: [cross-platform](<https://devfeed.tech/topics/cross-platform.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [built-by-touchlab](<https://devfeed.tech/tags/built-by-touchlab.md>), [code-sharing](<https://devfeed.tech/tags/code-sharing.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [ios](<https://devfeed.tech/tags/ios.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [native](<https://devfeed.tech/tags/native.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [press](<https://devfeed.tech/tags/press.md>), [robolectric](<https://devfeed.tech/tags/robolectric.md>), [thoughts](<https://devfeed.tech/tags/thoughts.md>)

### AI overview

The article explains Doppl, a set of tools and libraries built around j2objc for sharing Android business logic with iOS while keeping native user interfaces. It discusses applying MVP architecture, adding Dagger for dependency injection, and using sample test runners, while noting that iOS unit tests must currently be run from an Xcode app rather than the command line.

### Source excerpt

Are you building a product and decided to build native? Do you have some no trivial business logic? If so then be sure to read this latest post.

## MVVM-C A simple way to navigate

DevFeed: [MVVM-C A simple way to navigate](<https://devfeed.tech/articles/mvvm-c-a-simple-way-to-navigate-27947.md>)

Original publisher: [Read original article](<https://tech.trivago.com/post/2016-08-26-mvvmc/>)

Author: Susann Proszak Follow

Published: 2016-08-26T00:00:00Z

Content type: article

Language: en

Sources: [Trivago](<https://devfeed.tech/sources/trivago.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [software-architecture](<https://devfeed.tech/topics/software-architecture.md>), [mvc](<https://devfeed.tech/topics/mvc.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [architectures](<https://devfeed.tech/tags/architectures.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [cocoa-touch](<https://devfeed.tech/tags/cocoa-touch.md>), [code](<https://devfeed.tech/tags/code.md>), [coupling](<https://devfeed.tech/tags/coupling.md>), [delegation](<https://devfeed.tech/tags/delegation.md>), [design-patterns](<https://devfeed.tech/tags/design-patterns.md>), [flow](<https://devfeed.tech/tags/flow.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [ios-development](<https://devfeed.tech/tags/ios-development.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>)

### AI overview

The excerpt presents MVVM-C as a way to keep navigation out of views and view models, reducing coupling and supporting reuse. Coordinators own app flow: an AppCoordinator starts an AuthCoordinator for login, then creates a ListCoordinator after login; the list coordinator can open a detail screen. A coordinator's start method creates the model, view model and controller, then displays the screen. User actions reach coordinators through delegates, which start or dismiss child coordinators and restore the previous screen. The article says this makes navigation responsibilities clearer, view models easier to test in isolation, and coordinators reusable across entry points. The supplied text is an introduction with a small demo, not a full implementation.

### Source excerpt

When thinking about design patterns and architectures in iOS development, MVC might be the first thing that comes to mind for most of you. But throughout the last years, MVC got a really bad reputation. Probably a lot of you heard about MVC as the massive view controller.

## Data Binding: BindingAdapter

DevFeed: [Data Binding: BindingAdapter](<https://devfeed.tech/articles/data-binding-bindingadapter-26005.md>)

Original publisher: [Read original article](<https://medium.com/yazio-engineering/data-binding-bindingadapter-7d0824b1efff?source=rss-fbf9b6d94e65------2>)

Author: Paul Woitaschek

Published: 2016-01-31T22:16:59Z

Content type: tutorial

Language: en

Sources: [Paul Woitaschek](<https://devfeed.tech/sources/stories-by-paul-woitaschek-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>)

Tags: [adapter](<https://devfeed.tech/tags/adapter.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [code](<https://devfeed.tech/tags/code.md>), [data](<https://devfeed.tech/tags/data.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [library](<https://devfeed.tech/tags/library.md>), [recyclerview](<https://devfeed.tech/tags/recyclerview.md>), [textview](<https://devfeed.tech/tags/textview.md>), [viewholder](<https://devfeed.tech/tags/viewholder.md>)

### AI overview

The author reports that applying Android Data Binding in a RecyclerView ViewHolder reduced boilerplate by about 50%. To show completed items with strike-through text without calling findViewById, they define a static method annotated with @BindingAdapter("text:strike"). It sets or clears Paint.STRIKE_THRU_TEXT_FLAG on a TextView, and the layout binds the attribute to model.done(). The excerpt also notes that setting android:enabled from the inverse of model.done() already produced grey text with the support-library text color.

### Source excerpt

For a long time I did not investigate further into https://developer.android.com/tools/data-binding/guide.html but recently it just got my attention. Just like Kotlin or RxJava this was something that was constantly trying to get my attention so I decided to give it a try and to see how it works while writing my new notes app. And I must say: I'm impressed. I applied it on the ViewHolder of my RecyclerView and reduced the boilerplate code by about 50%. But there were some issues. Issues The biggest I had was manipulating the view. The grey text could be simply archieved by setting the view enabled based on the view model: android:enabled="@{!model.done()}" As the text was set to @color/abc_primary_text_material_light from the support library this automatically works. But how to set the strike through? I did not wanted to call all these `findViewById` any more as that would defeat the purpose of DataBinding. Solution It turned out there was a simple solution, called BindingAdapter> https://developer.android.com/reference/android/databinding/BindingAdapter.html Basically you just define a static method and annotate it as a binding adapter. So for strikeThrough it is: @BindingAdapter("text:strike") public static void setStrike(TextView text, boolean strike) { if (strike) { text.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { text.setPaintFlags(text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); } } So now you can set it just as a regular xml attribute: android:strike="@{model.done()}" Data Binding: BindingAdapter was originally published in Yazio Engineering on Medium, where people are continuing the conversation by highlighting and responding to this story.

## Rapid Guide on Two-Way Data Binding in Android

DevFeed: [Rapid Guide on Two-Way Data Binding in Android](<https://devfeed.tech/articles/rapid-guide-on-two-way-data-binding-in-android-38381.md>)

Original publisher: [Read original article](<https://meedamian.com/post/two-way-data-binding/>)

Author: hi@meedamian.com (Damian Mee)

Published: 2016-01-07T00:00:00Z

Content type: tutorial

Language: en

Sources: [Damian Mee | Blog | Portfolio | About](<https://devfeed.tech/sources/damian-mee-blog-portfolio-about.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Code](<https://devfeed.tech/topics/code.md>), [XML](<https://devfeed.tech/topics/xml.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [guide](<https://devfeed.tech/tags/guide.md>), [java](<https://devfeed.tech/tags/java.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [xml](<https://devfeed.tech/tags/xml.md>)

### AI overview

A concise Android tutorial showing the minimum setup needed to make two-way data binding work in an already configured project, using a simple UI, an Activity, a model, and a ViewModel.

### Source excerpt

This post is not a comprehensive introduction to data binding in Android, it's a required minimum to get two-way data binding to work, that assumes your project to be configured for data binding already (if it's not, start here). Complete source code available here or here. Structure: role file Activity: MainActivity.java Model: not relevant here View: activity_main.xml ViewModel: MainState.java Activity This one just glues stuff together: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.

## Task Commands revisited

DevFeed: [Task Commands revisited](<https://devfeed.tech/articles/task-commands-revisited-38411.md>)

Original publisher: [Read original article](<https://khmylov.com/2012/02/task-commands-revisited/>)

Author: Andrew Khmylov

Published: 2012-02-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [Despite the odds](<https://devfeed.tech/sources/despite-the-odds.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [async](<https://devfeed.tech/topics/async.md>), [Code](<https://devfeed.tech/topics/code.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [test](<https://devfeed.tech/topics/test.md>), [WPF](<https://devfeed.tech/topics/wpf.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [bitbucket](<https://devfeed.tech/tags/bitbucket.md>), [code](<https://devfeed.tech/tags/code.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [test](<https://devfeed.tech/tags/test.md>), [zip](<https://devfeed.tech/tags/zip.md>)

### AI overview

The article revisits an earlier TPL and MVVM command implementation, replacing its event-based asynchronous completion notification with an ExecuteAsync method that returns a Task. It presents an updated generic AsyncRelayCommand and explains its inner command, asynchronous execution, explicit ICommand.Execute implementation, and CanExecute handling.

### Source excerpt

Half a year ago I blogged about using TPL with MVVM in a test-friendly way. My solution turned out to be pretty handy, though it was far from being perfect. In this post I will describe what was wrong with the initial implementation and can we slightly improve it. Looking at that solution right now, I wonder why did I decide to use event async pattern (providing the ExecuteCompleted event) in the first place. The intention was to notify the caller about completion of the asynchronous operation. That is what System.Threading.Task is used for this days, isn't it? So the obvious solution is to expose the ExecuteAsync() method returning the Task instance on the command class. Here is the source of the updated AsyncRelayCommand: public class AsyncRelayCommand<T> : ICommand { private readonly RelayCommand<T> _internalCommand; private readonly Func<T, Task> _executeMethod; public event EventHandler CanExecuteChanged { add { _internalCommand.CanExecuteChanged += value; } remove { _internalCommand.CanExecuteChanged -= value; } } public AsyncRelayCommand(Func<T, Task> executeMethod, Predicate<T> canExecuteMethod) { if (executeMethod == null) { throw new ArgumentNullException("executeMethod"); } _executeMethod = executeMethod; _internalCommand = new RelayCommand<T>(_ => { }, canExecuteMethod); } public AsyncRelayCommand(Func<T, Task> executeMethod) : this(executeMethod, _ => true) { } void ICommand.Execute(object parameter) { if (parameter is T) { ExecuteAsync((T)parameter); } else throw new ArgumentException("Parameter should be of type " + typeof(T)); } public Task ExecuteAsync(T parameter) { return _executeMethod(parameter); } public bool CanExecute(object parameter) { return _internalCommand.CanExecute((T)parameter); } public void RaiseCanExecuteChanged() { _internalCommand.RaiseCanExecuteChanged(); } } The code is pretty straightforward, here are the key points: Create an inner command that responds to CanExecute, RaiseCanExecute calls and handles subscriptions to CanExec

## MVVM + TPL + Unit tests

DevFeed: [MVVM + TPL + Unit tests](<https://devfeed.tech/articles/mvvm-tpl-unit-tests-38407.md>)

Original publisher: [Read original article](<https://khmylov.com/2011/09/mvvm-tpl-unit-tests/>)

Author: Andrew Khmylov

Published: 2011-09-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Despite the odds](<https://devfeed.tech/sources/despite-the-odds.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [async](<https://devfeed.tech/topics/async.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [Web](<https://devfeed.tech/topics/web.md>), [WPF](<https://devfeed.tech/topics/wpf.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [callback](<https://devfeed.tech/tags/callback.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [tdd](<https://devfeed.tech/tags/tdd.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>)

### AI overview

The article discusses testing MVVM view-model commands that use the Task Parallel Library for asynchronous operations. It critiques static task creation for making dependencies difficult to mock and presents an ICommand wrapper that signals completion, allowing tests to synchronize with the asynchronous task.

### Source excerpt

UPD: This implementation didn't work as well as expected, please read the follow-up article. Recently I've faced an issue with writing unit tests for view model commands that use Task Parallel Library for asynchronous operations. Searching over the web was not really helpful, so I spent some time designing the approach to handle such cases. The most common way to start tasks with TPL is by using one of the static Task.Factory.StartNew(...) methods. If you are mockist TDD guy, this should already raise an alert in your head. Static members are not test-friendly and do not allow you to inject mock dependencies into your module. One may say that using tasks is just an implementation details and should not be concerned when testing the behavior. I would agree if we were speaking about a regular async method that allows you to perform some action when its execution completes (in a form of callback or event, doesn't really matter). That simply doesn't work for me because the asynchrony is used inside the command handler, so there is no way to specify the continuation outside of the view model. My first (and probably the bad one) idea was to create a service for running the tasks. Then it would be easy to mock it and run tasks synchronously. Hopefully, I rejected this solution - creating another dependency just didn't sound right. I decided to create a special ICommand implementation instead that would notify me when the execution completes. This should do the trick because you can always use the thread sync primitives in the test environment to wait on the asynchronous task. For simplicity's sake I just created the wrapper around RelayCommand from MVVM Light Toolkit (you could use your favorite library or implement the command from scratch yourself). public class AsyncDelegateCommand: ICommand { private readonly RelayCommand _innerCommand; public event EventHandler ExecuteCompleted; public event EventHandler CanExecuteChanged { add { _innerCommand.CanExecuteChanged += value

## Building advanced MVVM commands, Part 1

DevFeed: [Building advanced MVVM commands, Part 1](<https://devfeed.tech/articles/building-advanced-mvvm-commands-part-1-38403.md>)

Original publisher: [Read original article](<https://khmylov.com/2010/11/building-advanced-mvvm-commands-part-1/>)

Author: Andrew Khmylov

Published: 2010-11-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Despite the odds](<https://devfeed.tech/sources/despite-the-odds.md>)

Topics: [MVVM](<https://devfeed.tech/topics/mvvm.md>), [WPF](<https://devfeed.tech/topics/wpf.md>), [async](<https://devfeed.tech/topics/async.md>), [cancellation](<https://devfeed.tech/topics/cancellation.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [applications](<https://devfeed.tech/tags/applications.md>), [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [cancellation](<https://devfeed.tech/tags/cancellation.md>), [exception-handling](<https://devfeed.tech/tags/exception-handling.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [thread](<https://devfeed.tech/tags/thread.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

This tutorial presents an advanced DelegateCommand implementation for WPF and Silverlight applications using the MVVM pattern. It covers asynchronous execution, command states, cancellation, progress tracking, exception handling, UI updates through Dispatcher, and helper support for property-change notifications.

### Source excerpt

If you follow the MVVM pattern while developing your WPF/Silverlight applications, then you are probably familiar with DelegateCommand (or RelayCommand, as it is called sometimes) model. In brief: it is an implementation of WPF/Silverlight ICommand that allows you to specify what the command should do by passing some delegate that performs execution logic (instead of using CommandBindings). Pretty simple, but powerful pattern. Dealing with MVVM a lot, I've build my own implementation of this pattern that lets you simplify its usage. Here are some common features, that you have to handle on your own by using classic DelegateCommand: Support for asynchronous execution (usually solved by generating additional code in ViewModel that handles async calls and free/busy indicator). Different command states (Free/Busy/Failed with exception) + UI reactions for those states. Support for execution cancellation and progress tracking (required for asynchronous commands) Before we start, I offer you to imagine a common command execution timeline. In my opinion it looks like: Initialize some data (generally, UI settings - clear collections, set some indicators,...) Perform main execution logic (can be synchronous or asynchronous) Perform some actions after execution (update UI based on execution result) And don't forget about exception handling and correct cross-thread calls for asynchronous commands (all UI changes have to be performed through Dispatcher). Let's start with a little helper class, that I called PropertyChangedNotifier. It's just a wrapper around IPropertyChangedNotifier that has OnPropertyChanged(string propertyName) method. This method raises underlying IPropertyChangedNotifier.PropertyChanged event. Also this class has VerifyPropertyName method that verifies if specified string corresponds to the actual property (this method is marked with [Conditional("DEBUG")] attribute and is only used while debugging your applications to find out possible bugs with invalid prope

[Next page](<https://devfeed.tech/topics/mvvm.md?cursor=WyIyMDEwLTExLTI0VDAwOjAwOjAwKzAwOjAwIiwgIjI1NTcwNzlhLTUwOWItNGI1YS04ZTRkLWZmZmIzNmU1ZjU1MiJd>)