[英]GeoFire observeBlock are only called once in Swift project
This is my simplified code for GeoFire observing: The problem is that observeReady are only called once, on initial observation, however when new keys are entered, the observe function is working fine, but completion block is not getting called. 这是我简化的GeoFire观察代码:问题是,在初始观察时,observeReady仅被调用一次,但是,当输入新的键时,observe函数可以正常工作,但是不会调用完成块。
func startObserveNearbyPosts(location: CLLocation) {
let geoFireQuery = geoFire?.query(at: location, withRadius: 100)
geoFireQuery?.observe(.keyEntered, with: { (key, _) in
print("Key entered")
})
geoFireQuery?.observeReady {
print("Observe ready")
}
}
From the Geofire documentation : 从Geofire文档中 :
Sometimes you want to know when the data for all the initial keys has been loaded from the server and the corresponding events for those keys have been fired. 有时您想知道何时从服务器加载了所有初始密钥的数据,并且这些密钥的相应事件已被触发。
So it looks like observeReadyWithBlock
only gets called after the initial set of .keyEntered
has been fired, not for subsequent updates (unless you change the query). 所以它看起来像observeReadyWithBlock
初始设置后,仅会被调用.keyEntered
已经被解雇,而不是为后续更新(除非你改变了查询)。 Of course .keyEntered
should get called for each key that enters the queried range. 当然,应该为进入查询范围的每个键调用.keyEntered
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.