How to handle timeout in queries with Firebase

前端 未结 5 1721
终归单人心
终归单人心 2021-01-02 04:35

I noticed that if I execute a query in Firebase and the database server is not reachable, the callback waits just forever (or until the server is reachable again).

W

5条回答
  •  猫巷女王i
    2021-01-02 04:58

    you can manage yourself a timer controller that after x seconds remove the listener to you firebase reference. It's very simple, just one line of code in android for example.

    You can see the code for the web (Detaching Callbacks section): https://www.firebase.com/docs/web/guide/retrieving-data.html

    or for android (Detaching Callbacks section): https://www.firebase.com/docs/android/guide/retrieving-data.html#section-detaching

    same section for IOS ;)

提交回复
热议问题