Skip to content

Commit c737e3d

Browse files
devoncarewmosuem
andauthored
simplify hierarchy of ResponseFuture (#791)
* simplify hierarchy of ResponseFuture * dartfmt * update changelog --------- Co-authored-by: Moritz <[email protected]>
1 parent 79f277e commit c737e3d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- Require package:http 1.4.0
88
- Require package:lints 6.0.0
99
- Require package:protobuf 4.1.0
10+
- Simplify hierarchy of `ResponseFuture` (no longer have a private class in the
11+
type hierarchy)
1012

1113
## 4.1.0
1214

lib/src/client/common.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ abstract class Response {
4242
}
4343

4444
/// A gRPC response producing a single value.
45-
class ResponseFuture<R> extends DelegatingFuture<R>
46-
with _ResponseMixin<dynamic, R> {
47-
@override
45+
class ResponseFuture<R> extends DelegatingFuture<R> implements Response {
4846
final ClientCall<dynamic, R> _call;
4947

5048
static R _ensureOnlyOneResponse<R>(R? previous, R element) {
@@ -65,21 +63,25 @@ class ResponseFuture<R> extends DelegatingFuture<R>
6563
.fold<R?>(null, _ensureOnlyOneResponse)
6664
.then(_ensureOneResponse),
6765
);
66+
67+
@override
68+
Future<Map<String, String>> get headers => _call.headers;
69+
70+
@override
71+
Future<Map<String, String>> get trailers => _call.trailers;
72+
73+
@override
74+
Future<void> cancel() => _call.cancel();
6875
}
6976

7077
/// A gRPC response producing a stream of values.
71-
class ResponseStream<R> extends StreamView<R> with _ResponseMixin<dynamic, R> {
72-
@override
78+
class ResponseStream<R> extends StreamView<R> implements Response {
7379
final ClientCall<dynamic, R> _call;
7480

7581
ResponseStream(this._call) : super(_call.response);
7682

7783
@override
7884
ResponseFuture<R> get single => ResponseFuture(_call);
79-
}
80-
81-
mixin _ResponseMixin<Q, R> implements Response {
82-
ClientCall<Q, R> get _call;
8385

8486
@override
8587
Future<Map<String, String>> get headers => _call.headers;

0 commit comments

Comments
 (0)