mirror of https://github.com/grpc/grpc-dart.git
simplify hierarchy of ResponseFuture (#791)
* simplify hierarchy of ResponseFuture * dartfmt * update changelog --------- Co-authored-by: Moritz <mosum@google.com>
This commit is contained in:
parent
79f277e7b9
commit
c737e3d87e
|
|
@ -7,6 +7,8 @@
|
|||
- Require package:http 1.4.0
|
||||
- Require package:lints 6.0.0
|
||||
- Require package:protobuf 4.1.0
|
||||
- Simplify hierarchy of `ResponseFuture` (no longer have a private class in the
|
||||
type hierarchy)
|
||||
|
||||
## 4.1.0
|
||||
|
||||
|
|
|
|||
|
|
@ -42,9 +42,7 @@ abstract class Response {
|
|||
}
|
||||
|
||||
/// A gRPC response producing a single value.
|
||||
class ResponseFuture<R> extends DelegatingFuture<R>
|
||||
with _ResponseMixin<dynamic, R> {
|
||||
@override
|
||||
class ResponseFuture<R> extends DelegatingFuture<R> implements Response {
|
||||
final ClientCall<dynamic, R> _call;
|
||||
|
||||
static R _ensureOnlyOneResponse<R>(R? previous, R element) {
|
||||
|
|
@ -65,21 +63,25 @@ class ResponseFuture<R> extends DelegatingFuture<R>
|
|||
.fold<R?>(null, _ensureOnlyOneResponse)
|
||||
.then(_ensureOneResponse),
|
||||
);
|
||||
}
|
||||
|
||||
/// A gRPC response producing a stream of values.
|
||||
class ResponseStream<R> extends StreamView<R> with _ResponseMixin<dynamic, R> {
|
||||
@override
|
||||
final ClientCall<dynamic, R> _call;
|
||||
|
||||
ResponseStream(this._call) : super(_call.response);
|
||||
|
||||
@override
|
||||
ResponseFuture<R> get single => ResponseFuture(_call);
|
||||
}
|
||||
|
||||
mixin _ResponseMixin<Q, R> implements Response {
|
||||
ClientCall<Q, R> get _call;
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> get headers => _call.headers;
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> get trailers => _call.trailers;
|
||||
|
||||
@override
|
||||
Future<void> cancel() => _call.cancel();
|
||||
}
|
||||
|
||||
/// A gRPC response producing a stream of values.
|
||||
class ResponseStream<R> extends StreamView<R> implements Response {
|
||||
final ClientCall<dynamic, R> _call;
|
||||
|
||||
ResponseStream(this._call) : super(_call.response);
|
||||
|
||||
@override
|
||||
ResponseFuture<R> get single => ResponseFuture(_call);
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> get headers => _call.headers;
|
||||
|
|
|
|||
Loading…
Reference in New Issue