Do we need to use background thread for retrieving data using firebase?

前端 未结 3 502
生来不讨喜
生来不讨喜 2020-12-06 05:29

I\'ve an android app where I\'m retrieving data into a Fragment. And I believe that Firebase manages its asynchronous calls. But still I\'ve doubt the if we need to write th

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 05:43

    Firebase runs all of its callbacks asynchronously as documented https://www.firebase.com/docs/android/guide/retrieving-data.html . This is done through a web socket layer.

    If for example, you need to do a large amount of data processing on the result of the Firebase data update - you should probably spin up an AsyncTask to prevent the UI from blocking. This isn't any different from how you would normally approach data processing before being presented to the UI.

    The Firebase documentation covers how data is handled and the reason why you do not need to execute any background reads. You should probably spend some time reading the documentation.

提交回复
热议问题