I have been using parse-server
as my backend and now migrating all my stuff to FireStore
(specifically for storing additional user data). Now, with parse I could directly get the user data just by using ParseUser.getCurrentUser().getString(...)
. If I use FireStore
, I have created a users
collection and I can store a document
for each user and it also supports local storage with offline support. But the problem I am facing is that I always need to use asynchronous/callback methods to get data from a document
. Here is an example in android:
final DocumentReference docRef = mFirestore
.collection(USER_COLLECTION).document(mAuthApi.getCurrentUserId());
docRef.get(Source.CACHE).addOnCompleteListener(task -> {
if(task.isSuccessful()) {
......
} else {
......
}
});
Is there a way where we can directly get data synchronously from DocumentReference
assuming it is locally cached? Something like:
mFirestore.collection(USER_COLLECTION).document(mAuthApi.getCurrentUserId()).getString(...)
That would make things very easy for me as I need to replace ParseUser.getCurrentUser().getString(...)
with an equivalent FireStore
call in my entire code base.