My app needs to spawn a long-living process (that ...
# compose
s
My app needs to spawn a long-living process (that follows the app lifetime) and it has to communicate with it using stdin/stdout/stderr. I wanted to go full-compose, but it seems that it's still not possible to
rememberSaveable
a
Parcelable
(I need it to encapsulate the
Process
object); should I just declare an
object
at this point?
c
Copy code
What types can be saved is defined by [SaveableStateRegistry], by default everything which can be stored in the Bundle class can be saved.
Your
Parcelable
should work.
s
Is this correct then? It throws "unable to marshal value Process..."
Copy code
@Parcelize
data class ParcelableProcess(val value: @RawValue Process) : Parcelable

@Composable
fun rememberProcess(command: String): ParcelableProcess = rememberSaveable {
    ParcelableProcess(Runtime.getRuntime().exec(command))
}

@Composable
fun Test() {
    val process = rememberProcess(command = "whoami")
}
c
I don’t think this problem is related to Compose.
javal.lang.Process
is not
Parcelable
.
🙌 1