Annotation Interface Subscribe


@Retention(RUNTIME) @Target(METHOD) public @interface Subscribe
Annotation to put on public methods which wish to receive events.

A method annotated with this needs to have exactly one argument, this being some subclass of MMEvent. An instance of that class then needs to be registered with the event bus via EventBus.registerHandler(Object) for it to work. The exact name of the method is not important, and neither is how many of such methods are packed into a single class.

It's a good idea (but not required) to keep a reference to the instance containing the event handlers yourself after registering it, if only to avoid registering it multiple times.

To avoid resource leaks, event handlers need be explicitly unregistered. They can do this safely in their event handler methods.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    Priority of the event handler, default 0
  • Element Details

    • priority

      int priority
      Priority of the event handler, default 0
      Default:
      0