invoke

@JvmName(name = "create")
operator fun invoke(): EventBus

Creates a new EventBus with the default error handler (Throwable::printStackTrace).


@JvmName(name = "create")
operator fun invoke(asyncExecutor: Executor?): EventBus

Creates a new EventBus with an async executor for async handler dispatch.

Handlers annotated with @Subscribe(async = true) or registered with async = true will be dispatched on asyncExecutor. Pass null to get the same result as invoke with no arguments.

Parameters

asyncExecutor

Executor for async handlers; null disables async dispatch.


operator fun invoke(exceptionHandler: (Throwable) -> Unit): EventBus

Creates a new EventBus with a custom exception handler.

Kotlin callers use this overload; Java callers use createWithHandler.

Parameters

exceptionHandler

Invoked whenever a handler throws. Runs on the posting thread for sync handlers, or on the configured executor's thread for async handlers. If this handler itself throws, the secondary exception is printed to stderr as a last resort; it never propagates out of post/postAsync and never prevents remaining handlers from running.


operator fun invoke(asyncExecutor: Executor?, exceptionHandler: (Throwable) -> Unit): EventBus

Creates a new EventBus with both an async executor and a custom exception handler.

Parameters

asyncExecutor

Executor for async handlers; null disables async dispatch.

exceptionHandler

Invoked whenever a handler throws. Runs on the posting thread for sync handlers, or on the configured executor's thread for async handlers. If this handler itself throws, the secondary exception is printed to stderr as a last resort; it never propagates out of post/postAsync and never prevents remaining handlers from running.