Created
April 9, 2020 19:17
-
-
Save agent10/44583aed07d420191bfdd1b74d58854b to your computer and use it in GitHub Desktop.
Delay workaround for mpp for iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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