title: rxjava using Single to pass a parameter in the doOnSuccess
body: <pre><code>Java 8
  io.reactivex:rxjava:1.3.6
  kotlin 1.2.21
  </code></pre>
  
  <p>I am trying to pass a parameter in the doOnSuccess using a Single.</p>
  
  <p>However, I am getting an error, that I can't seem to solve.</p>
  
  <pre><code>class TranslateInteractor(val repository: Respository) {
      fun requestNetworkTranslated(message: String): Completable {
          return repository.fetchTranslation(message)
                  .doOnSuccess { handleTranslationResponse(message, it) }.toCompletable()
      }
  
      private fun handleTranslationResponse(message, String, translatedResponse: TranslatedResponse) {
          saveTranslation(
                  "",
                  translatedResponse.content,
                  translatedResponse.translationEngine)
      }
  
      private fun saveTranslation(message: String, content: String, engine: String) {
          /* Save to local storage */
      }
  }
  </code></pre>
  
  <p>The error is in the .doOnSuccess. As I want to pass the message to the handleTranslationResponse. </p>
  
  <pre><code>Type mismatch: inferred type is String but TranslatedResponse was expected
  </code></pre>
  
  <p>How can I pass the message and what I get from the TranslatedResponse back to the HandleTranslationResponse?</p>
  
  <p>The repository which is a java class that returns a single:</p>
  
  <pre><code>public class Respository {
      private NetworkAPI networkAPI;
  
      public Single&lt;TranslatedResponse&gt; fetchTranslation(final String message) {
          return networkAPI.fetchTranslation(new TranslateRequest(message));
      }
  }
  </code></pre>
  
  <p>My Data classes in Kotlin are:</p>
  
  <pre><code>data class TranslatedResponse(
          val content: String,
          val translationEngine: String)
  </code></pre>
  
  <p>And request</p>
  
  <pre><code>data class TranslateRequest(val message: String)
  </code></pre>
  
  <p>For the networkAPI I have the following in java snippet:</p>
  
  <pre><code>public interface NetworkAPI {
      Single&lt;TranslatedResponse&gt; fetchTranslation(TranslateRequest request);
  }
  </code></pre>
  
  <p>Many thanks for any suggestions,</p>