What problem does it solve?
This Skill provides authoritative rules and patterns for writing production-quality Kotlin Coroutines code on Android, ensuring structured concurrency, lifecycle safety, and adherence to modern best practices.
Core Features & Use Cases
- Asynchronous Operations: Efficiently handle background tasks, network calls, and database operations.
- Reactive Programming: Implement
Flow, StateFlow, and SharedFlow for real-time data updates.
- Lifecycle Management: Safely manage coroutine scopes tied to Android lifecycles (
viewModelScope, lifecycleScope).
- Error Handling & Testing: Robust strategies for managing exceptions and writing unit tests with
runTest.
- Use Case: When building an Android app, use this skill to implement a ViewModel that fetches user data from an API asynchronously and displays it safely, ensuring no memory leaks or crashes occur due to lifecycle changes.
Quick Start
Use the android-coroutines skill to implement a suspend function for fetching data from an API, ensuring it's main-safe and uses an injected Dispatcher.