Hi everyone. My goal is to be able to share flows ...
# multiplatform
d
Hi everyone. My goal is to be able to share flows in IOS app from a base shared viewmodel The issue stems from
expect
actual
modifiers I am following this article. When I define
commonMain
Copy code
import kotlinx.coroutines.flow.Flow

expect class CommonFlow<T>(flow: Flow<T>): Flow<T>
androidMain
Copy code
actual class CommonFlow<T> actual constructor(
    private val flow: Flow<T>,
) : Flow<T> by flow
I get a compile-time error:
Copy code
Actual constructor of 'CommonFlow' has no corresponding expected declaration The following declaration is incompatible because parameter types are different:
public constructor CommonFlow<T>(flow: Flow<T>) defined in com.example.quickpark.util.flows.CommonFlow
Any ideas 🤷 ?
Answer: Kotlin by delegate works only with interfaces. And of course
kotlinx.coroutines.flow.Flow
is an interface. Problem stems from
actual CommonFlow
implementation I got because by accident I imported
java.util.concurrent.Flow
which is a class and definitely something I had no intention on using think smart