Skip to content

Commit 036da7d

Browse files
tvolkertjakemac53
authored andcommitted
Make Stdin act like a Stream<Uint8List> (dart-archive/bazel_worker#39)
* Make Stdin act like a Stream<Uint8List> In preparation for dart-lang/sdk#36900 * Bump version, and add changelog entry
1 parent d0ea3c1 commit 036da7d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pkgs/bazel_worker/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.21
2+
3+
* Make `TestStdinAsync` behave like a `Stream<Uint8List>`
4+
15
## 0.1.20
26

37
* Close worker `outputStream` on `cancel`.

pkgs/bazel_worker/lib/testing.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:async';
66
import 'dart:collection';
77
import 'dart:io';
8+
import 'dart:typed_data';
89

910
import 'package:bazel_worker/bazel_worker.dart';
1011

@@ -50,12 +51,12 @@ class TestStdinSync implements TestStdin {
5051
/// Note: You must call [close] in order for the loop to exit properly.
5152
class TestStdinAsync implements TestStdin {
5253
/// Controls the stream for async delivery of bytes.
53-
final StreamController<List<int>> _controller = new StreamController();
54-
StreamController<List<int>> get controller => _controller;
54+
final StreamController<Uint8List> _controller = new StreamController();
55+
StreamController<Uint8List> get controller => _controller;
5556

5657
/// Adds all the [bytes] to this stream.
5758
void addInputBytes(List<int> bytes) {
58-
_controller.add(bytes);
59+
_controller.add(Uint8List.fromList(bytes));
5960
}
6061

6162
/// Closes this stream. This is necessary for the [AsyncWorkerLoop] to exit.
@@ -64,7 +65,7 @@ class TestStdinAsync implements TestStdin {
6465
}
6566

6667
@override
67-
StreamSubscription<List<int>> listen(onData(List<int> bytes),
68+
StreamSubscription<Uint8List> listen(onData(Uint8List bytes),
6869
{Function onError, void onDone(), bool cancelOnError}) {
6970
return _controller.stream.listen(onData,
7071
onError: onError, onDone: onDone, cancelOnError: cancelOnError);

pkgs/bazel_worker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: bazel_worker
2-
version: 0.1.20
2+
version: 0.1.21
33

44
description: Tools for creating a bazel persistent worker.
55
author: Dart Team <[email protected]>

0 commit comments

Comments
 (0)