1 year ago
#363941

Deen Gangen
Is there a way to wait for one stream's data before listening to another stream that is dependent on the first
I rely on more than one stream for the data in my app. In this specific situation I listen to the first stream which is dependent on User UID (Firebase Auth) which I already have. But the 2nd stream needs something returned from the 1st stream.
Extra Context: I am using the MultipleStreamViewModel as part of the stacked package (flutter).
class HomeViewModel extends MultipleStreamViewModel{
@override
Map<String, StreamData> get streamsMap => {
_userDataStream: StreamData<DocumentSnapshot<Map<String, dynamic>>>(
//This stream contain the groupID needed
_userService.getUserData(uid: uid),), //Stream
_userGroupsStream: StreamData<QuerySnapshot<Map<String, dynamic>>>(
//This Stream requires the groupID from the previous stream.
_userService.getGroupData(groupID groupID),), //Stream
}
}
I was hoping that the order I listed the streams would allow for the one before to get the information that the following one required, but that did not work.
flutter
google-cloud-firestore
stacked
flutter-streambuilder
0 Answers
Your Answer