Package-level declarations

Types

Link copied to clipboard
interface Cancellable

Optional interface for events that support cancellation.

Link copied to clipboard
interface Event

Marker interface for all events that can be dispatched through an EventBus.

Link copied to clipboard
interface EventBus

Central event dispatch interface.

Link copied to clipboard
interface Modifiable<T>

Optional interface for events that carry a mutable result value.

Link copied to clipboard
object Priority

Predefined priority constants for use with @Subscribe.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class Subscribe(val priority: Int = Priority.NORMAL)

Marks a method as an event handler to be discovered by an EventBus.

Link copied to clipboard

A handle returned by lambda-based EventBus.subscribe overloads.

Link copied to clipboard
interface TypedEventBus<E : Event>

A type-safe view over an EventBus that restricts post and subscribe to a specific event hierarchy E. Provides compile-time enforcement that only subtypes of E can be posted or subscribed to through this interface.

Functions

Link copied to clipboard
inline fun <T : Event> EventBus.isListening(): Boolean
inline fun <T : Event> TypedEventBus<*>.isListening(): Boolean

Returns true if at least one handler is registered for T or any of its supertypes.

Link copied to clipboard
inline fun <T : Event> EventBus.subscribe(priority: Int = Priority.NORMAL, noinline handler: (T) -> Unit): Subscription

Registers a lambda handler for event type T and returns a Subscription token.

inline fun <T : Event> TypedEventBus<in T>.subscribe(priority: Int = Priority.NORMAL, noinline handler: (T) -> Unit): Subscription

Registers a lambda handler for event type T on this TypedEventBus.

Link copied to clipboard
fun EventBus.subscribeAll(priority: Int = Priority.NORMAL, handler: (Event) -> Unit): Subscription

Registers a wildcard handler with Priority.NORMAL default.

fun TypedEventBus<*>.subscribeAll(priority: Int = Priority.NORMAL, handler: (Event) -> Unit): Subscription

Registers a wildcard handler on this TypedEventBus with Priority.NORMAL default.

Link copied to clipboard
inline fun <E : Event> EventBus.typed(): TypedEventBus<E>

Returns a TypedEventBus view over this bus restricted to subtypes of E.

fun <E : Event> EventBus.typed(rootClass: Class<E>): TypedEventBus<E>

Java interop overload of typed. The rootClass token is unused at runtime (generics are erased) but satisfies Java's type inference: