Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating UI based on StreamGroup.merge(streams).asBroadcastStream() #179

Open
ConstantNel opened this issue May 8, 2021 · 0 comments
Open
Labels
type-question A question about expected behavior or functionality

Comments

@ConstantNel
Copy link

Hi!

Firstly thank you so much for this package. I've been using it quite a lot recently and it's very nice!

I don't think this is a bug, rather a question.
I'm subscribing to a single StreamSubscription that listens to changes in a QuerySnapshot.
My problem is, I'm combining two streams in this subscription using StreamGroup.merge and asBroadCastStream.
When I do this, the changes in the StreamSubscription doesn't trigger.

Do you have any idea how I could solve this?

Any help would greatly be appreciated!

Cheers!

Below is my code for the Streams and the Subscription:

Combining Streams:

final List<Stream<QuerySnapshot>> streams = [];
      var chunks = [];
      for (var i = 0; i < teamUids.length; i += 10) {
        chunks.add(teamUids.sublist(
            i, i + 10 > teamUids.length ? teamUids.length : i + 10));
      }
      for (final List<String> chunk in chunks) {
        final Stream<QuerySnapshot> qs = _firestore
            .collection('liveGames')
            .where('teamUids', arrayContainsAny: chunk)
            .where('status', isEqualTo: 'live')
            .snapshots();

        streams.add(qs);
      }
      return StreamGroup.merge(streams).asBroadcastStream();

StreamSubscription:

_liveGamesStream =
          userRepository.grabFavTeamsLiveGames(teamUids).listen((event) {
        final List<LiveGameModel> games = state.liveGames
          ..addAll(liveGameListFromQuerySnapshot(event));
        emit(state.copyWith(blocStatus: BlocStatus.initial, liveGames: games));
      });
@lrhn lrhn added the type-question A question about expected behavior or functionality label May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

2 participants