Skip to content

Instantly share code, notes, and snippets.

@gastsail
Created November 15, 2019 17:48
Show Gist options
  • Save gastsail/99a5c5063cc31b90fbfc8b8dae555ed4 to your computer and use it in GitHub Desktop.
Save gastsail/99a5c5063cc31b90fbfc8b8dae555ed4 to your computer and use it in GitHub Desktop.
UserDao
class UserDao {
fun getUserName(userId:String): LiveData<Resource<String>> {
var userName = MutableLiveData<Resource<String>>()
FirebaseFirestore.getInstance()
.collection("users")
.document(userId)
.get()
.addOnSuccessListener {
userName.value = Resource.success(it.getString("name"))
}.addOnFailureListener {
userName.value = Resource.error("Error",it.message!!)
}
return userName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment