Skip to content

Instantly share code, notes, and snippets.

@gastsail
Last active December 21, 2019 16:41
Show Gist options
  • Save gastsail/8f43f1dda56a06ef9a1804bd267b974a to your computer and use it in GitHub Desktop.
Save gastsail/8f43f1dda56a06ef9a1804bd267b974a to your computer and use it in GitHub Desktop.
suspend fun getEventsDB(): Resource<MutableList<Event>>{
val myList = mutableListOf<Event>()
val eventList = FirebaseFirestore.getInstance().collection("events").get().await()
// we can do wathever we want with the events, for example get them all
for (document in eventList) {
val photoUrl = document.getString("photoUrl")
val eventName = document.getString("name")
val time = document.getString("time")
myList.add(Event(photoUrl!!, eventName!!, time!!))
}
return Resource.Success(myList)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment