> android-state
Standards for ViewModel, StateFlow, and UI State Patterns. Use when managing UI state with ViewModel, StateFlow, or UiState in Android. (triggers: **/*ViewModel.kt, **/*UiState.kt, viewmodel, stateflow, livedata, uistate)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/android-state?format=md"Android State Management
Priority: P0
Implementation Guidelines
ViewModel Pattern
- Exposure: Expose ONE
StateFlow<UiState>via.asStateFlow(). - Scope: Use
viewModelScopefor all coroutines. - Initialization: Trigger initial load in
initorLaunchedEffect(once).
UI State (LCE)
- Type: sealed interface
UiState(Loading, Content, Error). - Immutability: Data classes inside should be
@Immutable.
Flow Lifecycle
- Collection: Use
collectAsStateWithLifecycle()in Compose. - Hot Flows: Use
SharingStarted.WhileSubscribed(5000)for shared resources.
Anti-Patterns
- LiveData:
**No LiveData**: Use StateFlow. - Mutable State:
**No Mutable Public**: Expose read-only Flow. - Context:
**No Context in VM**: Memory Leak Risk.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)