What problem does it solve?
This Skill provides authoritative patterns for building robust, lifecycle-aware Kotlin coroutine code on Android, reducing crashes and boilerplate through structured concurrency and Flow usage.
Core Features & Use Cases
- Structured concurrency: correct launching, scope management, and cancellation across Android components.
- Lifecycle integration: leveraging viewModelScope, lifecycleScope, and repeatOnLifecycle for safe collection.
- Reactive streams: practical use of Flow, StateFlow, SharedFlow, and callbackFlow.
- Error handling & cancellation: employing CoroutineExceptionHandler, SupervisorJob, and cooperative cancellation patterns.
- Testing readiness: setting up TestDispatcher and runTest for reliable tests.
- Use cases: fetch API data, perform background work, and reflect UI state updates with minimal boilerplate.
Quick Start
Add coroutines support to your Android project, adopt viewModelScope for coroutines in ViewModels, inject a dispatcher through constructors, and collect flows within repeatOnLifecycle blocks. Use standard testing patterns (StandardTestDispatcher and runTest) to verify behavior.