LibreTube/app/src/main/java/com/github/libretube/extensions/AwaitQuery.kt

14 lines
221 B
Kotlin
Raw Normal View History

2022-09-22 21:22:00 +05:30
package com.github.libretube.extensions
fun <T> awaitQuery(
query: () -> T
2022-09-22 21:29:15 +05:30
): T {
2022-09-22 21:22:00 +05:30
var x: T? = null
val thread = Thread {
x = query.invoke()
}
thread.start()
thread.join()
return x!!
2022-09-22 21:29:15 +05:30
}