Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Swift - GeoFire removeObserver no funciona, buscando una solución, por favor

Descubrí que tanto removeObserver como .removeAllObservers() no funcionan en GeoFire, esperando otra solución para "salir" de esta observación (que sigue cargándose para siempre)

 var newRefHandle: FIRDatabaseHandle? var gFCircleQuery: GFCircleQuery? func findFUsersInOnePath(location: CLLocation, radius: Int, indexPath: String, completion: @escaping () -> ()){ var ids = 0 let geofireRef = usersRef.child(indexPath) if let geoFire = GeoFire(firebaseRef: geofireRef) { gFCircleQuery = geoFire.query(at: location, withRadius: Double(radius)) newRefHandle = gFCircleQuery?.observe(.keyEntered, with: { (key, location) in // if key fit some condition then perform some other firebase call to other database(async), afterwards: ids += 1 if (ids >= 3) { //RemoveObersver not working below... self.gFCircleQuery?.removeObserver(withFirebaseHandle: self.newRefHandle!) completion() } }) //I find that observeReady gets call right away despite we haven't complete code above gFCircleQuery?.observeReady({ completion() }) }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Supongo que todavía está recibiendo algunos eventos .keyEntered después de la llamada a removeObserver , que en realidad es de esperar.

GeoFire realiza una sola consulta para obtener todas las claves dentro del rango de su consulta y luego llama a su devolución de llamada .keyEntered para cada una de estas claves. Incluso si llama a removeObserver para la primera clave, GeoFire continuará llamando a la devolución de llamada .keyEntered con el resto de las claves que ya obtuvo de la base de datos.

Por esta razón, recomendaría eliminar el observador dentro del bloque listo para la consulta. El comportamiento no cambiará cuando lo haga, pero tendrá más sentido ya que se llama a ese bloque listo cuando GeoFire termina de informarle sobre el lote de claves.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!