title: How to simply replace android AsyncTask with RX / Coroutines and return a value?
body: <p>this method runs a database operation (returns a generated ID) and must be on background thread:</p>
  
  <p><code>fun insert(note: Note): Long{
      return noteDao.insert(note)
  }</code></p>
  
  <p>Is there a way to implement it using RX / Coroutines? (without using the <code>suspend</code> keyword)</p>
  
  <p>I currently use AsyncTask:</p>
  
  <pre><code>override fun insert(note: Note): Long {
      return InsertTask(this, noteDao).execute(note).get()
  }
  </code></pre>
  
  <p><code>private class InsertTask(noteRepository: NoteRepository, private val noteDao: NoteDao) : AsyncTask&lt;Note, Void, Long&gt;() {</code></p>
  
  <pre><code>    override fun doInBackground(vararg note: Note): Long {
          return noteDao.insert(note[0])
      }
  
      override fun onPostExecute(generatedId: Long) {
          getTheId(generatedId)
      }
  
      private fun getTheId( id: Long): Long {
          return id
      }
  }
  </code></pre>