Configure ViewModel state emission with StateFlow, sealed UiState classes, and lifecycle-safe collection in Android. Use when working with ViewModels, UiState patterns, or exposing state to Compose UI.
78
—
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
StateFlow<UiState> via .asStateFlow().viewModelScope for all coroutines.init block.See templates for ViewModel and UiState examples.
@Immutable.See templates for sealed UiState pattern.
collectAsStateWithLifecycle() in Compose.SharingStarted.WhileSubscribed(5000) for shared resources..asStateFlow() to consumers.StateFlow<UiState>.collectAsStateWithLifecycle()../gradlew test passes for ViewModel tests.611f52a
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.