Change all bare Future to Future<void> (#45)
Closes #35
It looks less like a potential bug and more explicitly expresses that
these functions don't return useful values.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60400e0..24564ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
available.
* Remove `StreamChannelTransformer.typed`. Use `.cast` on the transformed
channel instead.
+* Change `Future<dynamic>` returns to `Future<void>`.
## 1.7.0
diff --git a/lib/src/close_guarantee_channel.dart b/lib/src/close_guarantee_channel.dart
index c534a91..33296da 100644
--- a/lib/src/close_guarantee_channel.dart
+++ b/lib/src/close_guarantee_channel.dart
@@ -77,7 +77,7 @@
_CloseGuaranteeSink(StreamSink<T> inner, this._channel) : super(inner);
@override
- Future close() {
+ Future<void> close() {
var done = super.close();
_channel._disconnected = true;
if (_channel._subscription != null) {
diff --git a/lib/src/disconnector.dart b/lib/src/disconnector.dart
index 83defb8..69fbab7 100644
--- a/lib/src/disconnector.dart
+++ b/lib/src/disconnector.dart
@@ -33,7 +33,7 @@
/// Returns a future that completes when all inner sinks' [StreamSink.close]
/// futures have completed. Note that a [StreamController]'s sink won't close
/// until the corresponding stream has a listener.
- Future disconnect() => _disconnectMemo.runOnce(() {
+ Future<void> disconnect() => _disconnectMemo.runOnce(() {
var futures = _sinks.map((sink) => sink._disconnect()).toList();
_sinks.clear();
return Future.wait(futures, eagerError: true);
@@ -64,7 +64,7 @@
final StreamSink<T> _inner;
@override
- Future get done => _inner.done;
+ Future<void> get done => _inner.done;
/// Whether [Disconnector.disconnect] has been called.
var _isDisconnected = false;
@@ -108,7 +108,7 @@
}
@override
- Future addStream(Stream<T> stream) {
+ Future<void> addStream(Stream<T> stream) {
if (_closed) throw StateError("Cannot add stream after closing.");
if (_inAddStream) {
throw StateError("Cannot add stream while adding stream.");
@@ -125,7 +125,7 @@
}
@override
- Future close() {
+ Future<void> close() {
if (_inAddStream) {
throw StateError("Cannot close sink while adding stream.");
}
@@ -138,7 +138,7 @@
///
/// This closes the underlying sink and stops forwarding events. It returns
/// the [StreamSink.close] future for the underlying sink.
- Future _disconnect() {
+ Future<void> _disconnect() {
_isDisconnected = true;
var future = _inner.close();
diff --git a/lib/src/guarantee_channel.dart b/lib/src/guarantee_channel.dart
index ce7f707..d8add39 100644
--- a/lib/src/guarantee_channel.dart
+++ b/lib/src/guarantee_channel.dart
@@ -81,7 +81,7 @@
final GuaranteeChannel<T> _channel;
@override
- Future get done => _doneCompleter.future;
+ Future<void> get done => _doneCompleter.future;
final _doneCompleter = Completer();
/// Whether connection is disconnected.
@@ -157,7 +157,7 @@
}
@override
- Future addStream(Stream<T> stream) {
+ Future<void> addStream(Stream<T> stream) {
if (_closed) throw StateError("Cannot add stream after closing.");
if (_inAddStream) {
throw StateError("Cannot add stream while adding stream.");
@@ -174,7 +174,7 @@
}
@override
- Future close() {
+ Future<void> close() {
if (_inAddStream) {
throw StateError("Cannot close sink while adding stream.");
}
diff --git a/test/disconnector_test.dart b/test/disconnector_test.dart
index aefad28..0992b36 100644
--- a/test/disconnector_test.dart
+++ b/test/disconnector_test.dart
@@ -145,7 +145,7 @@
_CloseCompleterSink(StreamSink inner) : super(inner);
@override
- Future close() {
+ Future<void> close() {
super.close();
return completer.future;
}