title: Observing repository LiveData from ViewModel and notify UI
body: <p>Google says that is not possible to observe a LiveData from a ViewModel:</p>
  
  <blockquote>
    <p>[...] However ViewModel objects must never observe changes to
    lifecycle-aware observables, such as LiveData objects.[...]</p>
  </blockquote>
  
  <p>And I would handle the <code>repo.login()</code> result in the ViewModel and notify the UI thought the two <a href="https://github.com/googlesamples/android-architecture/blob/dev-todo-mvvm-live/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/SingleLiveEvent.java" rel="noreferrer">SingleLiveEvent</a>s, is it possible?</p>
  
  <pre><code>class Repository {
      // .... //
      fun login(user:String, password:String): LiveData&lt;Status&gt; { /* ... */ }
  }
  
  class LoginViewModel : ViewModel() {
  
      @Inject
      lateinit var repo: Repository
  
      private var auth = MutableLiveData&lt;User&gt;()
      private var showErrorEvent = SingleLiveEvent&lt;String&gt;()
      private var showSuccessEvent = SingleLiveEvent&lt;String&gt;()
  
      // Called from UI
      fun performLogin(user:User){
          repo.login(user.name, user.password)
          // We can't observe the result here 
          // and update error/success events
      }
  
      // Called from UI
      fun getErrorEvent() = showErrorEvent
  
      // Called from UI
      fun getSuccessEvent() = showSuccessEvent
  
  }
  </code></pre>