Priyesh
Priyesh

Reputation: 1313

How do i combine or merge two stream of firestore?

I've two stream

Stream<QuerySnapshot> s1 = users.where("uid",isNotEqualTo: "--").snapshots();
Stream<QuerySnapshot> s2 = groups.snapshots(); 

And i want single stream

return s1+s2;

I also tried StreamGroup but facing this same issue;

Please do not send link, If you can do it via code then that will be helpful a lot.

Upvotes: 1

Views: 196

Answers (1)

Priyesh
Priyesh

Reputation: 1313

CombineLatestStream is the solution.

CombineLatestStream<QuerySnapshot, List<QuerySnapshot>> roomStream() {
    try {
      Stream<QuerySnapshot> s1 = users.where("uid",isNotEqualTo: firebaseAuth.currentUser.uid).snapshots();
      Stream<QuerySnapshot> s2 = groupService.streamGroup();
      return CombineLatestStream.list<QuerySnapshot>([s1,s2]);
    } catch (e) {
      handleException(e);
      throw e;
    }
  }

Thanks pskink

Upvotes: 1

Related Questions