What problem does it solve?
This Skill provides guidance for mastering advanced asynchronous programming in Kotlin using coroutines, enabling robust, scalable concurrency patterns across AmethystMultiplatform projects.
Core Features & Use Cases
- Structured concurrency patterns (supervisorScope, coroutineScope) to isolate failures and ensure clean shutdown.
- Advanced Flow operators (flatMapLatest, combine, merge, shareIn, stateIn) for complex stream transformations.
- Channels and callbackFlow to bridge callbacks into reactive streams.
- Dispatcher management and context switching for optimal performance and responsiveness.
- Exception handling with CoroutineExceptionHandler and SupervisorJob to guard long-running services.
- Testing async code with runTest and Turbine for deterministic verification of flows.
- Nostr relay connection pools and subscriptions with backpressure handling in high-frequency streams.
- Delegation to kotlin-expert for basic StateFlow/SharedFlow patterns and nostr-expert for relay communication.
Quick Start
Begin by creating a supervisorScope-based relay pool, connect relays using callbackFlow, expose results via a hot flow with shareIn/stateIn, and validate behavior with runTest and Turbine.