subscribe

abstract fun subscribe(any: Any)

Registers an object as a subscriber.

All functions on any annotated with EventHandler or ExceptionHandler and having a supported signature are discovered and wired into the bus:

  • @EventHandler methods must accept exactly one parameter whose type implements Event and return void/Unit.

  • @ExceptionHandler methods may use any of the supported exception-handler shapes documented on ExceptionHandler.

The subscriber is held via a weak reference, so both its event handlers and exception handlers are automatically removed when the object becomes unreachable and is garbage-collected.

Calling subscribe for the same instance more than once is a no-op.

Parameters

any

the object containing handler methods.