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

CombineLatestStream.list wont take multiple instances of already combined Stream #656

Open
devkirch opened this issue Dec 31, 2021 · 2 comments
Labels

Comments

@devkirch
Copy link

devkirch commented Dec 31, 2021

Hello,

not sure if this is a bug or intendend behaviour.

You have multiple instances of a Stream combined with Rx.combineLatest2 like below

  Stream<List<Post>> feedstream()  {
    return Rx.combineLatest2(
        poststream().asBroadcastStream(), challengesstream().asBroadcastStream(),
            (List<Post> posts, List<Challenge> challenges) {
          return challenges.map((challenge) {
            return Post(
                description: challenge.description,
                challengeid: challenge.id,
                isvideo: true,
                mediaurl: challenge.videourl,
                creationdate: challenge.creationdate,
                thumbnail: challenge.thumbnail,
                userid: challenge.userid,
                id: challenge.id,
                ischallenge: true);
          }).toList() + posts;
        }).asBroadcastStream();
  }

If you want to add those Streams at runtime to a List which holds those Object and use CombineLatestStream.list, Streambuilder wont emit new values, only those who have been assigned at Start.

 _listofstreams!.add(feedstream());
  return StreamBuilder<List<List<Post>>>(
        stream: CombineLatestStream.list(_listofstreams!),
        builder: (context, posts) {
          if (!posts.hasData) {
            return Container();
          }
          if (posts.connectionState == ConnectionState.waiting) {
            return Container(); 
          }

If you instead use multiple Streams which have not been combined with Rx.combineLatest2, Streambuilder will emit all values.

@hoc081098
Copy link
Collaborator

hoc081098 commented Jan 3, 2022

I think that is expected behavior of combineLatest, combined Stream will emit only when all Streams emitted

@hoc081098
Copy link
Collaborator

Trying startWith operator on each Stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants