Search code examples
kotlinkotlin-multiplatform

How to postpone the execution of a piece of code in kotlin native?


We can execute a piece of code on the main thread with a specific delay on the android platform by using the postDelayed method of Handler 1

Is there an equivalent way when using Kotlin native to run on iOS devices?


Solution

  • You could use Kotlin Coroutine's delay() with Dispatchers.Default possibly from the native-mt branch of coroutines.

    You can read more here