title: How to call a method multiple times using RXJava - which operator do I use?
body: <p>I have a function which does a network call to retrieve data, and I need to call it 5 times.  My method: </p>
  
  <pre><code>@Throws(IOException::class)
  private fun getWeather(future : Int): String {
      var twitterURL = Constants.API_URL
      if (future &gt; 0) {
          twitterURL += "future$future.json"
      }
          val urlBuilder = HttpUrl.parse(Constants.API_URL).newBuilder()
          val url = urlBuilder.build().toString()
  
          val request = Request.Builder()
                  .url(url)
                  .build()
          val client = OkHttpClient()
          val response = client.newCall(request).execute()
          val body = response.body()
          return if (response.code() == HttpURLConnection.HTTP_OK) {
  
              body.string()
          } else {
  
              throw IOException("Bad Request: Server Response" + response.code().toString() + " " + response.message())
          }
  
  
  }
  </code></pre>
  
  <p>I'd like to use the observable model doing something like: </p>
  
  <pre><code>private val array = DoubleArray(5)
  Observable.fromArray(listOf(1, 2, 3, 4, 5))
        .subscribeOn(Schedulers.newThread()) 
        .observeOn(AndroidSchedulers.mainThread())) 
        //observation on the main thread
        .subscribe(object:Subscriber&lt;Int&gt;(){
          override fun onCompleted() {
              calculateStandardDeviation(array)
          }
  
          override fun onError(e: Throwable?) {
           //TODO : Handle error here
          }
  
          override fun onNext(t: Int?) {
           val string = getWeather(t)
           val gson = Gson()
           val weather = gson.fromJson(string,TwitterWeather::class.java)
           array[t-1] = weather.temperature
  
          }
         })
  </code></pre>
  
  <p>But really, onNext() runs on the main thread.  I want to run it all on the Schedulers.io() thread.  </p>