title: Android MVVM have view respond to async result
body: <p>I am working on creating my MVVM template project.
  The way MVVM work's is that the View observes changes to the VM and reacts to them. How would i implement that logic in the following example.</p>
  
  <p>View code:</p>
  
  <pre><code>fun addPost(): Unit {
      viewModel.addPost(dataSource.text.get(), dataSource.title.get(), { postID: Long -&gt;
          if (postID.equals(0)) {
              Toast.makeText(MyApp.instance.getContext(), "Error", Toast.LENGTH_LONG).show()
          } else {
              (arguments.get(ARG_RunOnPositiveDismiss) as (DMPost) -&gt; Unit)(DMPost(postID, MyOptions.User.GET()!!.UserID, dataSource.title.get(), dataSource.text.get()))
              dismiss()
          }
      })
  }
  </code></pre>
  
  <p>ViewModel code:</p>
  
  <pre><code>fun addPost(title:String,text:String,onSuccess: (Long) -&gt; Unit): Unit {
          rep.insertPost(DMPost(0, MyOptions.User.GET()!!.UserID, title, text),onSuccess)
  }
  </code></pre>
  
  <p>Repository code:</p>
  
  <pre><code>fun insertPost(post: DMPost, onSuccess: (Long) -&gt; Unit) {
      if (MyOptions.Online.GET()!!) {
          val client = retrofit.create(APIPost::class.java)
          val insertPost: Call&lt;Long&gt; = client.insertPost(post)
          insertPost.enqueue(object : Callback&lt;Long&gt; {
              override fun onResponse(call: Call&lt;Long&gt;, response: Response&lt;Long&gt;) {
                  if (response.isSuccessful) {
                      onSuccess(response.body()!!)
                  } else {
                      onSuccess(0)
                  }
              }
  
              override fun onFailure(call: Call&lt;Long&gt;, t: Throwable) {
                  onSuccess(0)
              }
          })
  
      } else {
          AsyncTask.execute {
              try {
                  onSuccess(daoPost.insertPost(EntityPost(post)))
              } catch (e: Exception) {
                  onSuccess(0)
              }
          }
      }
  }
  </code></pre>
  
  <p>I am assuming that i need to have 2 methods in my view, one for showing the error toast and the other for success.the view should observe a value on the VM and on a change on that value, should call one of those 2 methods.</p>
  
  <p>Is my assumption right?
  If yes, can someone write the code for that logic?</p>