You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I'm getting a problem with broadcast StreamGroup.
Specifically, when adding a new stream after all previous subscriptions to a broadcast StreamGroup have been canceled, the StreamGroup won't listen to the newly added stream.
Here's how to reproduce this problem:
import'package:async/async.dart';
voidmain() async {
final streamGroup =StreamGroup<String>.broadcast();
Stream<String> getFirstStream() async* {
var i =0;
while (true) {
awaitFuture.delayed(Duration(seconds:1));
yield'1st stream: ${i++}';
}
}
// Add the first single subscription streamawait streamGroup.add(getFirstStream());
final firstSubs = streamGroup.stream.listen((event) {
print(event);
});
awaitFuture.delayed(Duration(seconds:3));
// * Cancel the only subscription to the StreamGroup, putting it into dormantawait firstSubs.cancel();
Stream<String> getSecondStream() async* {
var i =0;
while (true) {
awaitFuture.delayed(Duration(seconds:1));
yield'2nd stream: ${i++}';
}
}
// Add another single subscription streamawait streamGroup.add(getSecondStream());
// * Start to listen to the StreamGroup again, which should emits events from both the 1st stream and the 2nd stream
streamGroup.stream.listen((event) {
print(event);
});
}
Expected behavior:
Events from both the 1st stream and the 2nd stream are emitted by the StreamGroup.
Actual behavior:
Only Events from the 1st stream are emitted. The 2nd stream is ignored.
Hi. I'm getting a problem with broadcast
StreamGroup
.Specifically, when adding a new stream after all previous subscriptions to a broadcast
StreamGroup
have been canceled, theStreamGroup
won't listen to the newly added stream.Here's how to reproduce this problem:
Expected behavior:
Events from both the 1st stream and the 2nd stream are emitted by the
StreamGroup
.Actual behavior:
Only Events from the 1st stream are emitted. The 2nd stream is ignored.
Proposal:
I believe the problem is in this line
https://github.com/dart-lang/async/blob/f1c8882c927af68df6786124c94e857de0fa22c1/lib/src/stream_group.dart#L195
Here, since the 1st stream is already being listened and have value
!= null
, the function returns without listening to subsequent streams.Therefore, it should be
continue
instead ofreturn
.Thank you guys for this very helpful package.
The text was updated successfully, but these errors were encountered: