subscribe Static
Registers all static methods on klass annotated with @Subscribe.
"Static" means:
Java:
staticmethods.Kotlin: methods annotated with
@JvmStaticinside acompanion objectorobject.
Kotlin object caveat: plain (non-@JvmStatic) methods on a Kotlin object are compiled as instance methods on the singleton, not static methods. They will not be found by subscribeStatic. Either annotate them with @JvmStatic, or pass the singleton instance to subscribe instead:
object MyListener {
@JvmStatic @Subscribe // found by subscribeStatic
fun onA(e: EventA) { }
@Subscribe // found by subscribe(MyListener)
fun onB(e: EventB) { }
}
bus.subscribeStatic(MyListener::class.java) // picks up onA
bus.subscribe(MyListener) // picks up onBContent copied to clipboard