Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit e0c41e0

Browse files
authored
Make StreamQueue start listening immediately to broadcast streams. (#119)
When a `StreamQueue` is created for a broadcast stream, it didn't use to listen to the stream immediately, which means that any events sent before the first call to `next` (or any other queue request) would be silently lost. That makes an initial `peek` operation change the behavior of the queue, which is confusing to users.
1 parent f708371 commit e0c41e0

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.2
2+
3+
* `StreamQueue` starts listening immediately to broadcast strings.
4+
15
## 2.4.1
26

37
* Deprecate `DelegatingStream.typed`. Use `Stream.cast` instead.

lib/src/stream_queue.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ class StreamQueue<T> {
118118
factory StreamQueue(Stream<T> source) => StreamQueue._(source);
119119

120120
// Private generative constructor to avoid subclasses.
121-
StreamQueue._(this._source);
121+
StreamQueue._(this._source) {
122+
// Start listening immediately if we could otherwise lose events.
123+
if (_source.isBroadcast) {
124+
_ensureListening();
125+
_pause();
126+
}
127+
}
122128

123129
/// Asks if the stream has any more events.
124130
///

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: async
2-
version: 2.4.1
2+
version: 2.4.2
33

44
description: Utility functions and classes related to the 'dart:async' library.
55
homepage: https://www.github.com/dart-lang/async

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy