Giter Club home page Giter Club logo

Comments (5)

natebosch avatar natebosch commented on June 28, 2024 1

We have a test covering this - there is not problem in general merging two streams.

test("buffers events from multiple sources", () async {
var controller1 = new StreamController<String>();
streamGroup.add(controller1.stream);
controller1.add("first");
controller1.close();
var controller2 = new StreamController<String>();
streamGroup.add(controller2.stream);
controller2.add("second");
controller2.close();
await flushMicrotasks();
expect(streamGroup.close(), completes);
expect(streamGroup.stream.toList(),
completion(unorderedEquals(["first", "second"])));
});

Perhaps your stream is a broadcast Stream? Those events are explicitly not buffered and so any events that come through before you have a listener on the group's stream will be lost.

test("doesn't buffer events from a broadcast stream", () async {
var controller = new StreamController<String>.broadcast();
streamGroup.add(controller.stream);
controller.add("first");
controller.add("second");
controller.close();
await flushMicrotasks();
expect(streamGroup.close(), completes);
expect(streamGroup.stream.toList(), completion(isEmpty));
});

You might find the SingleSubscriptionStreamTransformer useful to convert a broadcast Stream to a single subscription stream and buffer events until there is a listener.

from async.

brilliant-ember avatar brilliant-ember commented on June 28, 2024

this this stackoverflow tracks the issue https://stackoverflow.com/questions/51214217/combine-streams-from-firestore-in-flutter

from async.

brilliant-ember avatar brilliant-ember commented on June 28, 2024

Turns out that this issue also affects the RX Observable
https://stackoverflow.com/questions/51368676/flutter-stream-builder-does-not-work-correctly-when-it-is-fed-with-observable1/52843628#52843628

from async.

natebosch avatar natebosch commented on June 28, 2024

Turns out that this issue also affects the RX Observable

Note that package:rxdart does not depend on package:async and has a completely independent implementation. If there were a bug here it would not impact that package. This is another signal that the problem is coming from the input streams, not the merging.

from async.

brilliant-ember avatar brilliant-ember commented on June 28, 2024

Update, Observable did pass both stream contents to the function as tested with
streamGroup.map((convert){ convert.documents.forEach((f){print(f.data["name"]);});}).listen(print);
however the Flutter streamBuilder widget failed to update the UI with both values.
Conclusion issue is not in the stream merging, but in displaying the content to the UI.
Thanks @natebosch for your timely response.

from async.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.