kotlin-flow

from pluginagentmarketplace/custom-plugin-kotlin

Kotlin Development Plugin

3 stars1 forksUpdated Jan 5, 2026
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-kotlin --skill kotlin-flow

SKILL.md

Kotlin Flow Skill

Reactive programming with Kotlin Flow.

Topics Covered

Cold vs Hot Flows

// Cold Flow - starts fresh for each collector
fun loadData(): Flow<Data> = flow {
    emit(fetchData())
}

// Hot Flow - shared state
private val _state = MutableStateFlow(State())
val state: StateFlow<State> = _state.asStateFlow()

Flow Operators

fun searchUsers(query: Flow<String>): Flow<List<User>> =
    query
        .debounce(300)
        .filter { it.length >= 2 }
        .distinctUntilChanged()
        .flatMapLatest { term -> userRepository.search(term) }
        .catch { emit(emptyList()) }

Combining Flows

val dashboard: Flow<Dashboard> = combine(
    userFlow,
    ordersFlow,
    notificationsFlow
) { user, orders, notifications ->
    Dashboard(user, orders.size, notifications.count())
}

Testing with Turbine

@Test
fun `flow emits values`() = runTest {
    viewModel.state.test {
        assertThat(awaitItem().isLoading).isFalse()
        viewModel.load()
        assertThat(awaitItem().isLoading).isTrue()
        advanceUntilIdle()
        assertThat(awaitItem().data).isNotNull()
    }
}

Troubleshooting

IssueResolution
Flow never emitsAdd terminal operator (collect, first)
Stale data in UIUse stateIn or shareIn properly

Usage

Skill("kotlin-flow")

Repository Stats

Stars3
Forks1
LicenseOther