Created
August 23, 2018 21:19
-
-
Save madsunrise/769704182871a46b33ded367ff781765 to your computer and use it in GitHub Desktop.
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
| fun <T> runSynchronously(asyncFunc: (callback: CallbackWithResult<T>) -> UUID): T { | |
| var result: T? = null | |
| asyncFunc.invoke(object:CallbackWithResult<T> { | |
| override fun onResult(res: T) { | |
| result = res; | |
| } | |
| override fun onError() { | |
| throw RuntimeException(); | |
| } | |
| }) | |
| while (true) { | |
| result?.let { return it } | |
| Thread.sleep(250); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment