Skip to content

Instantly share code, notes, and snippets.

@madsunrise
Created August 23, 2018 21:19
Show Gist options
  • Save madsunrise/769704182871a46b33ded367ff781765 to your computer and use it in GitHub Desktop.
Save madsunrise/769704182871a46b33ded367ff781765 to your computer and use it in GitHub Desktop.
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