Skip to content

Instantly share code, notes, and snippets.

@gastsail
Created November 17, 2019 16:35
Show Gist options
  • Save gastsail/a7ad68a436b9431d5d933f28781184b7 to your computer and use it in GitHub Desktop.
Save gastsail/a7ad68a436b9431d5d933f28781184b7 to your computer and use it in GitHub Desktop.
UserDaoGist
fun postEventData(email:String,name:String,surname:String,dollarqty:Int):LiveData<Resource<Boolean>>{
val datastatus = MutableLiveData<Resource<Boolean>>()
val userData = User(email,name,surname,dollarqty)
FirebaseFirestore.getInstance()
.collection("purchases")
.add(userData)
.addOnCompleteListener {
if(it.isSuccessful) datastatus.value = Resource.success(true)
}.addOnFailureListener {
datastatus.value = Resource.error(it.message!!,false)
}
return datastatus
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment