【发布时间】:2019-11-23 07:02:00
【问题描述】:
如果查询成功但 kotlin 是异步的,我会尝试返回一个布尔值。
private fun checkDidAdd(geoPoint: GeoPoint, fullAddress: String):Boolean {
var added = false
scope.launch {
val docRef = db.collection("listings")
.get()
.addOnSuccessListener { result ->
for (document in result) {
//todo
}
added = true
}
}.addOnFailureListener { exception ->
Log.d("TAG", "Error getting documents: ", exception)
}
println("done!!")
}
return added
}
【问题讨论】:
标签: android firebase kotlin synchronization blocking