Not sure what you mean by blocking exactly, but I ...
# tornadofx
l
Not sure what you mean by blocking exactly, but I finally found a suspending way to await for modal (or any stage) being hidden:
Copy code
suspend fun Stage.awaitHidden() {
    lateinit var listener: InvalidationListener
    val property = onHiddenProperty()
    try {
        suspendCancellableCoroutine<Unit> { c ->
            listener = InvalidationListener {
                c.resume(Unit)
            }
            property.addListener(listener)
        }
    } finally {
        property.removeListener(listener)
    }
}