compose-state-holder-ui-split

Decouple Compose screen business logic from UI wiring with a state-holder composable.

908|42|Updated May 12, 2026
One-click install
npx skills add https://github.com/chrisbanes/skills --skill compose-state-holder-ui-split-chrisbanes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compose-state-holder-ui-split
Source: https://github.com/chrisbanes/skills/tree/main/skills/compose-state-holder-ui-split
Command: npx skills add https://github.com/chrisbanes/skills --skill compose-state-holder-ui-split-chrisbanes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Decouple business logic and UI wiring in Compose screens to improve testability and previewability.

Core Features & Use Cases

  • Separate state-holder wiring from UI rendering, enabling testable, preview-friendly screens.
  • Use a small public state-holder composable to connect to ViewModels, components, or navigators while keeping UI pure.
  • Preserve layout responsibilities in the UI composable while exposing state via a plain UI state object and callbacks.

Quick Start

Create a state-holder composable that wires to your ViewModel, and a separate UI composable that consumes a plain state and callbacks.

Frequently Asked Questions about compose-state-holder-ui-split

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate state logic from UI in Jetpack Compose to improve testability?

To separate state logic from UI in Jetpack Compose, create a small state-holder composable that collects state and wires callbacks, keeping the UI composable layout-focused and consuming a plain UI state object.

What is the state-holder pattern in Compose for decoupling business logic?

The state-holder pattern in Compose uses a public composable to connect to ViewModels and handle navigation, exposing a plain UI state and callback-based navigation to the UI component. This keeps layout concerns isolated from business logic wiring.

How to make Compose screens preview-friendly when using a ViewModel?

To make Compose screens preview-friendly with a ViewModel, split state-holder wiring from UI rendering. The UI composable consumes a plain state object and callbacks, allowing you to render previews without needing the ViewModel or business logic dependencies.

Can I keep navigation callbacks in the state-holder while leaving layout to the UI composable?

Yes, the state-holder composable handles callback-based navigation and wires to the ViewModel, while the UI composable remains strictly layout-focused. This preserves layout responsibilities in the UI component and exposes navigation through plain callbacks.

When should I split state wiring from UI rendering in Jetpack Compose?

Split state wiring from UI rendering in Jetpack Compose when a screen uses a ViewModel, collects state or effects, handles navigation, and wires callbacks. This pattern improves testability and previewability for screens with complex state management.