kotlin-coroutines

Kotlin coroutines - structured concurrency, Flows, exception handling

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "kotlin-coroutines" with this command: npx skills add pluginagentmarketplace/custom-plugin-kotlin/pluginagentmarketplace-custom-plugin-kotlin-kotlin-coroutines

Kotlin Coroutines Skill

Master asynchronous programming with structured concurrency.

Topics Covered

Structured Concurrency

// ✅ Structured - cancellation propagates
class Repository(private val scope: CoroutineScope) {
    suspend fun load() = withContext(Dispatchers.IO) { fetch() }
}

// ❌ Avoid GlobalScope
GlobalScope.launch { /* leaks */ }

Exception Handling

suspend fun loadData() = supervisorScope {
    val a = async { fetchA() }
    val b = async { fetchB() }
    Result(a.awaitOrNull(), b.awaitOrNull())
}

// Never swallow CancellationException
catch (e: Exception) {
    if (e is CancellationException) throw e
}

Testing

@Test
fun test() = runTest {
    val vm = ViewModel(testDispatcher)
    vm.load()
    advanceUntilIdle()
    assertThat(vm.state.value.data).isNotNull()
}

Troubleshooting

IssueResolution
Coroutine leakUse structured scopes, not GlobalScope
Test hangsInject TestDispatcher, use advanceUntilIdle()

Usage

Skill("kotlin-coroutines")

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

kotlin-compose

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-android

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-testing

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-ktor

No summary provided by upstream source.

Repository SourceNeeds Review