Claude-skill-registry kotlin-flow
Kotlin Flow - StateFlow, SharedFlow, operators, testing
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/kotlin-flow" ~/.claude/skills/majiayu000-claude-skill-registry-kotlin-flow && rm -rf "$T"
manifest:
skills/data/kotlin-flow/SKILL.mdsource content
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
| Issue | Resolution |
|---|---|
| Flow never emits | Add terminal operator (collect, first) |
| Stale data in UI | Use stateIn or shareIn properly |
Usage
Skill("kotlin-flow")