I am unable to use the ```exitProcess ``` function...
# multiplatform
v
I am unable to use the
Copy code
exitProcess
function, I am assuming that this is the fault of kotlin multiplatform?
c
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.system/exit-process.html This method only exists for JVM and Native targets. It is not in the common standard library.
v
is there no multiplatform way to do this?
c
No
What process would you be exiting if running this on JS?
☝️ 1
You can make an `expect`/`actual` method for “exiting”, and then invoke that method from your common code
eg: commonMain:
Copy code
expect fun exitApplication()
jvmMain:
Copy code
actual fun exitApplication() {
  exitProcess(0)
}
…etc bindings for other targets you have configured
v
For JS I assume window.close() is similar?
c
probably ¯\_(ツ)_/¯ depends on the need of your application
Depending on your application, closing the entire tab may be a jarring experience
v
This is true but I imagine that if you call exitProcess or similar, your intention was not the smoother user experience
😂 1
👍 1
😋 1
104 Views