Really neat solution 👏.
I just didn't understood one thing here that why we need both postAtFrontOfQueue() & post()? Wouldn't just post() do the trick for us like shown below? 🤔 With or without postAtFrontOfQueue() we essentially want to call posted.complete(Unit) at the end of the main thread queue.
Choreographer.getInstance().postFrameCallback {
handler.post {
posted.complete(Unit)
}
}