Skip to content

Instantly share code, notes, and snippets.

@agent10
Created April 9, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agent10/44583aed07d420191bfdd1b74d58854b to your computer and use it in GitHub Desktop.
Save agent10/44583aed07d420191bfdd1b74d58854b to your computer and use it in GitHub Desktop.
Delay workaround for mpp for iOS
actual suspend fun customDelay(timeMillis: Long) {
suspendCancellableCoroutine<Unit> { cont ->
val ntime = dispatch_time(DISPATCH_TIME_NOW, timeMillis * NSEC_PER_MSEC.toLong())
dispatch_after(ntime, dispatch_get_main_queue()) {
cont.resume(Unit)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment