in class MyViewModel create

    val userLiveData =MutableLiveData<User>()

and getter

    fun getUserLiveData(id: String): MutableLiveData<User> {
            return userLiveData
    }

    fun getUser(id: String){
    val disposableUser = repository.getUser(id)
    .subscribe({
        userLivedata.postValue(it)
    })

}

And in activity or Fragment called

   myViewModel.getUserLiveData.observe(this, Observer { it ->
      //TODO
    })
   myViewModel.getUser(...)

And Now in ViewModel you have object User (userLiveData.getValue())


Write method in Activity doSomethingWithUser(user: User)

And in your livedata

myViewModel.getUser(editText.text.toString()).observe(this, Observer { it ->
            (requireActivity() as MainActivity).doSomethingWithUser(it)
        })