Slide 42
Slide 42 text
@CodingDoug
Implement LiveData with Firestore document updates
override fun onEvent(snap: DocumentSnapshot?, e: FirebaseFirestoreException?) {
if (snap != null && snap.exists()) {
val model = StockPrice(
snap.id,
snap.getDouble("price")!!.toFloat()
)
// Here you go, all my admiring observers! Go update your UI!
setValue(model)
}
else if (e != null) {
TODO("You should handle errors. Do as I say, not as I do.")
}
}