https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
v

Vishnu Shrikar

10/11/2023, 4:28 AM
I am unable to use the
Copy code
exitProcess
function, I am assuming that this is the fault of kotlin multiplatform?
c

chr

10/11/2023, 5:09 AM
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

Vishnu Shrikar

10/11/2023, 5:27 AM
is there no multiplatform way to do this?
c

chr

10/11/2023, 5:35 AM
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

Vishnu Shrikar

10/11/2023, 5:39 AM
For JS I assume window.close() is similar?
c

chr

10/11/2023, 5:41 AM
probably ¯\_(ツ)_/¯ depends on the need of your application
Depending on your application, closing the entire tab may be a jarring experience
v

Vishnu Shrikar

10/11/2023, 5:52 AM
This is true but I imagine that if you call exitProcess or similar, your intention was not the smoother user experience
😂 1
👍 1
😋 1
2 Views