What problem does it solve?
Cross-platform Kotlin Multiplatform projects often duplicate coroutine boilerplate across common and platform modules. This Skill provides a centralized, reusable coroutine configuration to unify dispatchers, scopes, and flow sharing.
Core Features & Use Cases
-
Platform Dispatchers via expect/actual: PlatformDispatchers.main, PlatformDispatchers.io, PlatformDispatchers.default, and PlatformDispatchers.unconfined for consistent control across Android, iOS, and native targets.
-
Shared Coroutine Scopes: ApplicationScope, ViewScope, and useCaseScope to tie lifecycles to app components and business logic, improving testability and lifecycle safety.
-
Flow Sharing & Caching: shareIn and cachedIn utilities to reuse streams across UI layers and caches across scopes.
-
Patterns & Reuse: BaseRepository, BaseUseCase, and FlowUseCase abstractions to reduce boilerplate and standardize async operations.
-
Use Case Scenarios: asynchronous data fetch, background tasks, and lifecycle-aware streams in multiplatform apps.
Quick Start
Install the shared-coroutines module into your Kotlin Multiplatform project, replace direct Dispatcher usage with PlatformDispatchers, initialize ApplicationScope and ViewScope, and adopt the shareIn and cachedIn helpers in your flows.