GeoFire observeBlock 在 Swift 项目中只被调用一次
GeoFire observeBlock are only called once in Swift project
这是我对 GeoFire 观察的简化代码:
问题是 observeReady 在初始观察时只被调用一次,但是当输入新键时,观察函数工作正常,但没有调用完成块。
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")
}
}
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.
因此看起来 observeReadyWithBlock
仅在 .keyEntered
的 初始 集被触发后被调用,而不是用于后续更新(除非您更改询问)。当然 .keyEntered
应该为每个进入查询范围的键调用。
这是我对 GeoFire 观察的简化代码: 问题是 observeReady 在初始观察时只被调用一次,但是当输入新键时,观察函数工作正常,但没有调用完成块。
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")
}
}
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.
因此看起来 observeReadyWithBlock
仅在 .keyEntered
的 初始 集被触发后被调用,而不是用于后续更新(除非您更改询问)。当然 .keyEntered
应该为每个进入查询范围的键调用。