diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 19956d899..f7e395956 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -4,6 +4,7 @@ - Refactor code for presenting record instances. - [#2074](https://github.com/dart-lang/webdev/pull/2074) - Display record types concisely. - [#2070](https://github.com/dart-lang/webdev/pull/2070) - Display type objects concisely. - [#2103](https://github.com/dart-lang/webdev/pull/2103) +- Check for new events more often in batched stream. - [#2123](https://github.com/dart-lang/webdev/pull/2123) ## 19.0.0 diff --git a/dwds/lib/shared/batched_stream.dart b/dwds/lib/shared/batched_stream.dart index 9cb16fc1f..7237246dc 100644 --- a/dwds/lib/shared/batched_stream.dart +++ b/dwds/lib/shared/batched_stream.dart @@ -3,14 +3,15 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:math'; import 'package:async/async.dart'; import 'package:dwds/src/utilities/shared.dart'; /// Stream controller allowing to batch events. class BatchedStreamController { static const _defaultBatchDelayMilliseconds = 1000; - static const _checkDelayMilliseconds = 100; + final int _checkDelayMilliseconds; final int _batchDelayMilliseconds; final StreamController _inputController; @@ -26,6 +27,7 @@ class BatchedStreamController { BatchedStreamController({ int delay = _defaultBatchDelayMilliseconds, }) : _batchDelayMilliseconds = delay, + _checkDelayMilliseconds = max(delay ~/ 10, 1), _inputController = StreamController(), _outputController = StreamController>() { _inputQueue = StreamQueue(_inputController.stream); @@ -46,7 +48,7 @@ class BatchedStreamController { /// Send events to the output in a batch every [_batchDelayMilliseconds]. Future _batchAndSendEvents() async { - const duration = Duration(milliseconds: _checkDelayMilliseconds); + final duration = Duration(milliseconds: _checkDelayMilliseconds); final buffer = []; // Batch events every `_batchDelayMilliseconds`.