// FIR_IDENTICAL // ISSUE: KT-65584 // WITH_STDLIB fun interface Flow { suspend fun collect(collector: FlowCollector) } fun interface FlowCollector { suspend fun emit(value: T) } inline fun Flow.flatMapLatest(crossinline transform: suspend (value: T) -> Flow) = Flow { collector -> collect { it1 -> transform(it1).collect { it2 -> collector.emit(it2) } } } fun flowOf(value: T): Flow = Flow { collector -> collector.emit(value) } inline fun Flow.map(crossinline transform: suspend (value: T) -> R): Flow = Flow { collector -> collect { collector.emit(transform(it)) } } // ------ class StationId class Playable class Entity(val stationId: StationId) class State(val playbackEntity: Entity) internal suspend fun init( queueState: State, state: Flow ) { state .flatMapLatest { playable -> flowOf(playable).map { Triple(it, playable, queueState.playbackEntity.stationId) } } .collect { (likeState, playable, stationId) -> } }