Hi again, I have problems using `subscribeAsState`...
# decompose
j
Hi again, I have problems using
subscribeAsState
:
Copy code
interface IRootComponent {
    val dialogSlot: Value<ChildSlot<*, DialogComponent>>
}
My RootContent:
Copy code
@Composable
fun RootContent(component: RootComponent, modifier: Modifier = Modifier) {
val dialogSlot by component.dialogSlot.subscribeAsState()
    dialogSlot.child?.instance?.also {
        DialogContent(dialogComponent = it)
    }
}
and then I get a compilation error saying:
Copy code
Type 'State<ChildSlot<*, DialogComponent>>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
j
god, damn it. I had to manually import it. Wonder why its not working ...
a
Usually IDE automatically suggests importing this thing, but so far it has been working not so well.
j
What do you mean by "has been working not so well"? Is it a known issue for decompose?
Why I try auto-import, AndroidStudio imports
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
instead
is it due experimental decompose version?
a
No, that is rather a bug in the IDE - https://youtrack.jetbrains.com/issue/KTIJ-16966. It's marked as fixed a long time ago, but sometimes it still doesn't work. If you search Slack for "getvalue import", you will find lots of messages.
"subscribeAsState" is a normal function that returns Compose
State
, so
State#getValue
extension function has to be imported in order for
by
delegation to work.
j
ok, thanks. Feels like I am falling into every pit that exists
a
That's alright, we are using bleeding edge tech 😁
j
another thing is the @Preview Annotation which also does not work
and other things:
image.png
but it compiles and works as expected
anyways ... I got my first slotNavigation working ... that feels great 😉
a
The AlertDialog error seems valid - it shouldn't be available on all platforms I guess
j
Hm ok, but I do not understand it completely. I thought that AlertDialog would be available through compose.material or compose.material3. Just wondering because NavigationRail seems to be available. Is there a good way to figure out what is available for commonMain?
a
You can try asking in #compose. Not everything is supported on all platforms.
j
I did in #compose-ios 😉
sorry to bother you, but I think there will be more come up. thanks so far
a
So a dev from JB couldn't reproduce the issue. Would it be possible to provide a reproducer? They believe it's a bug.
Here is an anti-reproducer where they claim everything works fine - https://github.com/daugeldauge/wizardly/blob/decompose/shared/build.gradle.kts
j
will check the anti-reproducer
anti-reproducer fails building/setup:
Copy code
Caused by: java.lang.IllegalStateException: Executing of 'xcodebuild -project Pods.xcodeproj -scheme Base64 -sdk iphoneos -configuration Release' failed with code 65 and message:
will try to build an empty minimal sample
hm ... just wonder what should excactly fail. It seems to work in my minimal sample. First AS asks for the import
Copy code
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
Afterwards AS asks for the import:
Copy code
import androidx.compose.runtime.getValue
This also works in my other project
a
Oh! Turned out I responded in a wrong thread, confused this thread with another one! https://kotlinlang.slack.com/archives/C03H3N51SKT/p1683725214780229
So that reproducer is about exporting things with cocoapods
j
hm, ok. Maybe I will have a look later on.
222 Views