Is firestore callback method run in a separate thread?

Tags: , , , ,



I am fetching Firestore data through RX observable. Is it required to subscribe to it in a separate thread or Firestore callback run off the main thread by default? Also please share any references regarding the Firestore unit test.

Answer

Is it required to subscribe to it in a separate thread or Firestore callback run off the main thread by default?

Both Cloud Firestore and Firebase Realtime Database client already run all network operations in a background thread. This means that all operations take place without blocking your main thread. Trying to put the operation in an AsyncTask, for example, does not give any benefits at all.

Also please share any references regarding the Firestore unit test.

There are a bunch of ways to unit test. For example, if you are using Android Studio, please check the official documentation:

https://firebase.google.com/docs/test-lab/android/android-studio



Source: stackoverflow