post Suspend
suspend fun <T : Event> EventBus.postSuspend(event: T, context: CoroutineContext = EmptyCoroutineContext): T
Dispatches event on context and suspends until all handlers have finished.
Delegates to EventBus.post on the specified coroutine context. When called with no context argument, dispatch runs on the caller's current coroutine context with no thread hop. Pass an explicit context to shift dispatch to a specific dispatcher:
launch(Dispatchers.IO) {
bus.postSuspend(PlayerJumpEvent("Steve")) // stays on IO
bus.postSuspend(PlayerJumpEvent("Steve"), Dispatchers.Default) // shifts to Default
}Content copied to clipboard
For most cases EventBus.post is sufficient. postSuspend is useful when you need explicit dispatcher control over where dispatch runs.
Parameters
context
The coroutine context to dispatch on; defaults to the caller's context.