title: Can't Trigger EventBus from Inside Http Request (RxJava, Kotlin, Android)
body: <p>I have an eventbus that's "working" within an <code>onResume</code> function in my <code>mainActivity</code>. I can push events through my EventBus, but <strong>only</strong> when those events don't come from inside an http request. Of course, my use case is to get the results of an http request, push them to an event bus, and have that event bus send the result to a fragment. So this is an issue.</p>
  
  <p>Here is my <code>mainActivity</code> so far: </p>
  
  <pre><code>class MainActivity: AppCompatActivity(){
  
      var mainMessage: Disposable?=null
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          setSupportActionBar(toolbar)
          getSupportActionBar()?.hide();
  
          view_pager.adapter = TabsAdapter(supportFragmentManager)
          tab_layout.setupWithViewPager(view_pager)
      }
  
      public override fun onStart() {
          super.onStart()
          mainMessage = MainEventBus.INSTANCE.toObserverable().subscribe({
              println("MESSAGE SENT FROM MAINACTIVITY")
              println(it)
          })
      }
  
      public override fun onStop() {
          mainMessage?.dispose()
          super.onStop()
      }
  
      override fun onResume() {
          super.onResume()
          val testEvent = MainEventBus.Companion.KeyValue(key = "testkey", value = "keyvalue")
          MainEventBus.INSTANCE.send(testEvent)
          weatherRequests()
      }
  
      private fun weatherRequests(){
          "http://api.openweathermap.org/data/2.5/weather?q=Austin,us&amp;appid=abd532567a4d169ee04f6597584ba084".httpGet().responseJson { _, _, result -&gt;
              //do something with response
              result.fold(success = { json -&gt;
                  println("success from json request to weatherAPI")
                  val weatherArray = result.get().obj().getJSONArray("weather").get(0) as JSONObject
                  println("value of main in weatherArray:" + weatherArray["main"])
                  println("value of description in weatherArray:" + weatherArray["description"])
                  println("value of icon in weatherArray: " + weatherArray["icon"])
                  val mainWeatherEvent = MainEventBus.Companion.KeyValue(key="mainWeather", value = weatherArray["main"].toString())
                  val descriptionWeatherEvent = MainEventBus.Companion.KeyValue(key="descriptionWeather", value = weatherArray["description"].toString())
                  val weatherurl = "http://openweathermap.org/img/w/"+weatherArray["icon"].toString()+".png"
                  val iconWeatherEvent = MainEventBus.Companion.KeyValue(key="iconWeather", value = weatherurl)
  
                  println("BEFORE SENDING EVENTBUS ITEMS")
                  MainEventBus.INSTANCE.send(mainWeatherEvent)
                  MainEventBus.INSTANCE.send(descriptionWeatherEvent)
                  MainEventBus.INSTANCE.send(iconWeatherEvent)
                  println("AFTER SENDING EVENTBUS ITEMS")
  
              }, failure = { error -&gt;
                  Log.e("qdp error", error.toString())
              })
          }
  
          Log.d("aftertag","after fuel Request")
      }
  
  }
  </code></pre>
  
  <p>So my output sees this: </p>
  
  <pre><code>I/System.out: INSIDE EVENTBUS
  I/System.out: VALUE OF KEYVALUE
  I/System.out: KeyValue(key=testkey, value=keyvalue)
  I/System.out: MESSAGE SENT FROM MAINACTIVITY
  I/System.out: KeyValue(key=testkey, value=keyvalue)
  </code></pre>
  
  <p>Which is the test event that is fired directly from my <code>onResume</code> function. But I get no trigger notifications from the http request event bus calls from within my <code>weatherRequests</code> function. Why aren't these firing?</p>
  
  <p>My event bus is very simple, and I don't think it's the problem. (I think there's an issue with my lifecycle somehow in <code>mainActivity</code>). But I'll include it just for completeness:</p>
  
  <pre><code>enum class MainEventBus {
  
      INSTANCE;
  
      companion object {
          data class KeyValue(var key: String, var value: String)
      }
  
      private val bus = PublishSubject.create&lt;KeyValue&gt;() // the actual publisher handling all of the events
  
      fun send(keyValue: KeyValue) {
          println("INSIDE EVENTBUS")
          println("VALUE OF KEYVALUE")
          println(keyValue)
          bus.onNext(keyValue)
  //        bus.onNext({key, message}) // the message being sent to all subscribers
      }
  
      fun toObserverable(): Observable&lt;KeyValue&gt; {
          return bus // return the publisher itself as an observable to subscribe to
      }
  
  }
  </code></pre>