# Simplifying State Management with Compose

DevFeed: [Simplifying State Management with Compose](<https://devfeed.tech/articles/simplifying-state-management-with-compose-20043.md>)

Original publisher: [Read original article](<https://technology.doximity.com/articles/simplifying-state-management-with-compose>)

Author: Doximity

Published: 2023-07-05T19:45:00Z

Content type: article

Language: en

Sources: [Doximity](<https://devfeed.tech/sources/doximity.md>)

Topics: [state-management](<https://devfeed.tech/topics/state-management.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [UI/UX Design](<https://devfeed.tech/topics/ui-ux-design.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [app](<https://devfeed.tech/tags/app.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [clean-architecture](<https://devfeed.tech/tags/clean-architecture.md>), [compose](<https://devfeed.tech/tags/compose.md>), [compose-ui](<https://devfeed.tech/tags/compose-ui.md>), [development](<https://devfeed.tech/tags/development.md>), [development-process](<https://devfeed.tech/tags/development-process.md>), [error](<https://devfeed.tech/tags/error.md>), [experiment](<https://devfeed.tech/tags/experiment.md>), [experiments](<https://devfeed.tech/tags/experiments.md>), [flexible](<https://devfeed.tech/tags/flexible.md>), [framework](<https://devfeed.tech/tags/framework.md>), [improvement](<https://devfeed.tech/tags/improvement.md>), [inspiration](<https://devfeed.tech/tags/inspiration.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interoperability](<https://devfeed.tech/tags/interoperability.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [state](<https://devfeed.tech/tags/state.md>), [state-management](<https://devfeed.tech/tags/state-management.md>)

## AI overview

Doximity's Amion 6.0.0 team experimented with using the Compose Runtime to manage screen state in place of ViewModels, aiming to improve the UI and presentation logic while fitting its existing architecture. The excerpt describes a clean-architecture split between UI components and presentation logic that produces screen state. Producing a screen state involves evaluating data, user inputs, and app or device conditions, including permissions and connectivity; the state stays the same until an underlying input changes. The team chose a flexible pattern with smoother interoperability over Circuit, which they viewed as requiring significant framework buy-in. This is part one of a two-part article; the supplied excerpt ends as it begins explaining Compose Runtime's role, so it does not show the implementation or results in detail.

## Source excerpt

The recent release of Doximity's refreshed physician scheduling tool Amion involved a significant overhaul of the user interface (UI) layer using Jetpack Compose. As part of the development process, we decided to experiment with shifting from ViewModels to utilizing the Compose Runtime for managing screen state. This article explores the motivations behind this approach and demonstrates an overall improvement to the view layer and presentation logic using the patterns developed in Amion 6.0.0. Note: This is part one of a two-part article. In part two, we will build a note-taking app using the foundations covered here. Understanding the Presentation Layer The Android team at Doximity builds apps following the basic principles of clean architecture, which involves separating the app into layers, each with their own responsibilities. In our app, we have a view layer, responsible for rendering UI components (Compose UI, XML views, etc.), and a presentation logic layer, responsible for producing screen state. Every navigable point in the app corresponds to one or more UI components and is associated with one or more screen state producers. Inspiration and Initial Experiments The decision to leverage Compose for managing state was inspired by (at the risk of sounding like r/mAndroidDev) Jake Wharton's article The State of Managing State (with Compose). While the release of Circuit occurred midway through our development, it was deemed more of a framework that required significant buy-in, whereas we aimed to build a flexible pattern with smoother interoperability with our existing architecture, that at the time mostly utilized ViewModel with XML and Compose UI. When we think about the presentation layer in Android as developers, we have to think about: What is the state of the screen? That is, not just when the user first sees it, but what does it look like when it's loading, what happens when there is an error, how will the state of components of the screen interact, and