title: RxAndroid - retry observable on click
body: <p>I'm using rxAndroid and rxKotlin in my Android app to handle network requests asynchronously. Now I would like to retry a failed network request only after click on Snackbar button.</p>
  
  <p>My code now:</p>
  
  <pre><code>val citiesService = ApiFactory.citiesService
  
  citiesService.cities()
      .subscribeOn(Schedulers.newThread()) // fetch List&lt;String&gt;
      .flatMap { Observable.from(it) }     // convert to sequence of String
      .flatMap { city -&gt;
          citiesService.coordinates(city)  // fetch DoubleArray
              .map { City(city, it) }      // convert to City(String, DoubleArray)
          }
      .toList()
      .observeOn(AndroidSchedulers.mainThread())
      .doOnNext {
          listView.setOnItemClickListener { adapterView, view, position, id -&gt;
              onItemClick(it[position])
          }
      }
      .map { it.map { it.getName(activity) } }
      .subscribe(
          { listAdapter = setupAdapter(it) },
          { showErrorSnackbar() }  // handle error
      )
  
  fun showErrorSnackbar() {
          Snackbar.make(listView, getString(R.string.not_available_msg), Snackbar.LENGTH_INDEFINITE)
                  .setAction(getString(R.string.snack_retry_btn), {
                      // retry observable
                  })
                  .show()
      }
  </code></pre>
  
  <p>Cities interface for retrofit:</p>
  
  <pre><code>interface CitiesService {
  
      @GET("api/v1/cities")
      fun cities(): Observable&lt;List&lt;String&gt;&gt;
  
      @GET("api/v1/cities/{city}/coordinates")
      fun coordinates(@Path("city") city: String): Observable&lt;DoubleArray&gt;
  }
  </code></pre>
  
  <p>Api factory:</p>
  
  <pre><code>object ApiFactory {
  
      val citiesService: CitiesService
          get() = retrofit.create(CitiesService::class.java)
  
      private val retrofit: Retrofit
          get() = Retrofit
              .Builder()
              .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
              .addConverterFactory(GsonConverterFactory.create())
              .baseUrl(BASE_URL)
              .build()
  }
  </code></pre>
  
  <p>How can I restart the observable in such way?</p>