I am trying to use observeAsState on a LiveData, b...
# compose
c
I am trying to use observeAsState on a LiveData, but I am getting:
Type 'State<List<MuNowNext>>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
I don't get that error message. I see State has this extension:
Copy code
State<T>.getValue(thisObj: Any?, property: KProperty<*>)
An Nothing? is not Any?, so why does it want a Nothing? ? Code is:
Copy code
@Composable
fun ChannelsList(channels: LiveData<List<MuNowNext>>) {
    val channelsList by channels.observeAsState(initial = emptyList())
a
You just need to:
Copy code
import androidx.compose.setValue
import androidx.compose.getValue
Sometimes IntelliJ doesn't always suggest
alt + enter
to import them for you, at least in my experience.
👍 2
c
Thanks you! The type resolving is a big mess after I added compose. Types from the Kotlin Multiplatform libs are not resolved. But it compiles after your suggestion was added.