0

Right now I am removing observer with DispatchQueue.main.asyncAfter(deadline: .now() + 2) {}. It should never take more that 2 seconds to load the data; this is swift not python. However, it is still a very unelegant solution. Also, ObserveSingleEvent is not feasible to use here (query cache etc)

florida27
  • 67
  • 1
  • 7
  • Can you post the code where you are loading your data and removing the observers? – lpizzinidev Apr 23 '21 at 15:33
  • 1
    Are you asking how to [Remove Observers](https://firebase.google.com/docs/database/ios/lists-of-data#detach_listeners)? And the API is [Detaching observers](https://firebase.google.com/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabaseReference#detaching-observers). There are a bunch of Q&A's about using [removeObserverWithHandle](https://stackoverflow.com/search?q=%5Bfirebase%5D%5Bswift%5D+removeObserverWithHandle) here on SO as well. – Jay Apr 23 '21 at 15:48
  • In your example https://stackoverflow.com/questions/41449938/how-to-remove-a-geofire-handle-for-the-following-observe-in-swift how do you prevent someFunc() and stopObserving() from running asynchronously? If you call both in the same override function, initially myPostHandle is nil (before the event is fired). stopObserving() should only be called once data is loaded. – florida27 Apr 24 '21 at 16:55

0 Answers0