https://kotlinlang.org logo
Title
r

Robert Jaros

12/14/2021, 6:31 PM
I was using this simple code till
1.6.0-RC
, but in
1.6.0-RC2
it's not working anymore because the
collect
extension function was removed with https://github.com/Kotlin/kotlinx.coroutines/pull/3047 :
val stateFlow = MutableStateFlow(State())
        val actionFlow = MutableSharedFlow<Action>()
        launch {
            actionFlow.collect {
                stateFlow.value = stateReducer(stateFlow.value, it)
            }
        }
What is the correct way to implement this?
This seems to work:
launch {
            actionFlow.onEach {
                stateFlow.value = stateReducer(stateFlow.value, it)
            }.collect()
        }
Removing not deprecated, public functions should be more clearly marked as a breaking change in the changelog.
a

Alex Vanyo

12/14/2021, 6:43 PM
https://github.com/Kotlin/kotlinx.coroutines/issues/3078 There is a bug for this there. It looks like a commit just went into
develop
that is removing the
@InternalCoroutinesApi
on the actual
Flow.collect
, which I think should allow old source code to compile as-is
h

hfhbd

12/14/2021, 6:45 PM
It's a RC version and this bug was not intentional, the annotation was not removed.
r

Robert Jaros

12/14/2021, 6:46 PM
Thanks for info!