android-state
/android-state
Konfiguruje emisję stanu ViewModel z StateFlow, SharedFlow i uszczelnionymi klasami UiState w Android.
- Autor
- HoangNguyen0403 ↗
- Repozytorium
- agent-skills-standard ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 22.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 3
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 22.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Konfiguruje emisję stanu ViewModel z StateFlow, SharedFlow i uszczelnionymi klasami UiState w Android.
Oryginalny opis (EN)
Configure ViewModel state emission with StateFlow, SharedFlow, and sealed UiState classes in Android. Use for state modeling and sharing policies; defer generic lifecycle collection, navigation-event plumbing, Hilt injection, test code, and configuration-change recipes to their specific skills.
Jak działa
- Priority: P0 (CRITICAL)
- 1. Structure ViewModel
- 2. Define UI State (LCE Pattern)
- 3. Collect State Lifecycle-Safely
- Anti-Patterns
- Verification
- References
Podgląd SKILL.md
---
name: android-state
description: Configure ViewModel state emission with StateFlow, SharedFlow, and sealed UiState classes in Android. Use for state modeling and sharing policies; defer generic lifecycle collection, navigation-event plumbing, Hilt injection, test code, and configuration-change recipes to their specific skills.
metadata:
triggers:
files:
- '**/*ViewModel.kt'
- '**/*UiState.kt'
keywords:
- viewmodel
- stateflow
- livedata
- uistate
- MutableStateFlow
- collectAsState
- viewModelScope
- UiState
---
# Android State Management
## **Priority: P0 (CRITICAL)**
## 1. Structure ViewModel
- Expose ONE `StateFlow<UiState>` via `.asStateFlow()`.
- Use `viewModelScope` for all coroutines.
- Trigger initial load in `init` block.
See [templates](references/implementation.md) for ViewModel and UiState examples.
## 2. Define UI State (LCE Pattern)
- Use sealed interface with Loading, Content, Error variants.
- Mark data classes `@Immutable`.
See [templates](references/implementation.md) for sealed UiState pattern.
## 3. Collect State Lifecycle-Safely
- Use `collectAsStateWithLifecycle()` in Compose.
- Use `SharingStarted.WhileSubscribed(5000)` for shared resources.
## Anti-Patterns
- **No LiveData for New Code**: Use StateFlow — lifecycle-safe and Compose-compatible.
- **No Public MutableStateFlow**: Expose only `.asStateFlow()` to consumers.
- **No Context in ViewModel**: Leaks Activity. Use Application context if truly needed.
## Verification
- [ ] Each ViewModel exposes exactly one `StateFlow<UiState>`.
- [ ] UiState is a sealed interface with Loading, Content, Error variants.
- [ ] UI collects with `collectAsStateWithLifecycle()`.
- [ ] `./gradlew test` passes for ViewModel tests.
## References
- [Templates](references/implementation.md)
Pliki w paczce (3)
- SKILL.md 2 KB
- evals/evals.json 3 KB
- references/implementation.md 2 KB
Wersje
W bazie nie ma innych skilli o nazwie android-state.
Migawka bazy z 13.11.2026 · wersja paczki 58111fa59306 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 95kotlin-flows
Pomaga w pracy z Flow, StateFlow, SharedFlow i Channel: wybór strumienia, operatory, zbieranie z cyklem życia i stan UI. - 90Android Architecture
Porządkuje strukturę aplikacji Android: MVVM lub MVI, ViewModel, StateFlow, repozytoria, nawigację i wstrzykiwanie zależności. - 100kotlin-android
Pomaga budować i naprawiać natywne aplikacje Android w Kotlinie i Jetpack Compose w warstwowej architekturze UDF: ViewModel, StateFlow, Hilt, Room, Retrofit, coroutines i Navigation. - 100android-architecture-components-mvvm
Pomaga strukturyzować produkcyjne aplikacje Android w MVVM z ViewModel, StateFlow, LiveData i Clean Architecture. - 100jetpack-compose-expert
Wspiera projekty natywnego Androida w Jetpack Compose (Kotlin 2.x): budowa ekranów, zarządzanie stanem, nawigacja, DI (Hilt), Room i testy z Material 3 oraz ViewModel i StateFlow. - 100android-architecture
Stosuje Clean Architecture, modularyzację i jednokierunkowy przepływ danych w projektach Android przy ustalaniu struktury projektu i modułów.