Hot questions for Using EventBus in kotlin

Question:

Please if you want to devote question write reason to improve.

The problem is I dont know how to implement the eventbus in presenter with Kotlin. It works fine if I implement and subscribe in activity class but when I am trying the same code in the presenter I got an exception. Might be something in Kotlin way of implementation. There must be nothing wrong with eventbus setting up because implementation in view works fine

My activity => constructor of presenter

    private val mMainPresenter = MainPresenter(this, MainInteractor(), this)

My presenter

class MainPresenter(var mMainView: MainInterface?, val mMainInteractor: MainInteractor, val mContext : Context){

/**
 * Checking if user have language otherwise show list of games
 */
 fun checkingLanguage() {
    if(mMainInteractor.getUserLanguage() == "") mMainView?.callLanguageDialog()
    else EventBus.getDefault().post(LanguageEvent (mMainInteractor.getUserLanguage()))
}

fun registerSubscribers() {
    if (!EventBus.getDefault().isRegistered(mContext)) {
        EventBus.getDefault().register(mContext)
    }
}

@Subscribe
fun inflateGamesList(event: LanguageEvent){
    mMainView?.showGamesList(event.language)
} }

Exception code

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.example.a3802256.zzzz, PID: 13508
              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.a3802256.zzzz/com.example.a3802256.zzzz.view.main.MainActivity}: org.greenrobot.eventbus.EventBusException: Subscriber class com.example.a3802256.zzzz.view.main.MainActivity and its super classes have no public methods with the @Subscribe annotation
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                  at android.app.ActivityThread.-wrap12(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:154)
                  at android.app.ActivityThread.main(ActivityThread.java:6119)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
               Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.example.a3802256.zzzz.view.main.MainActivity and its super classes have no public methods with the @Subscribe annotation
                  at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:67)
                  at org.greenrobot.eventbus.EventBus.register(EventBus.java:140)
                  at com.example.a3802256.zzzz.view.main.MainPresenter.registerSubscribers(MainPresenter.kt:20)
                  at com.example.a3802256.zzzz.view.main.MainActivity.onCreate(MainActivity.kt:32)
                  at android.app.Activity.performCreate(Activity.java:6679)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                  at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:154) 
                  at android.app.ActivityThread.main(ActivityThread.java:6119) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

Answer:

If you want to listen to events in presenter, you should register presenter, and not activity (context). So,

fun registerSubscribers() {
    if (!EventBus.getDefault().isRegistered(this)) {
        EventBus.getDefault().register(this)
    }
}