Add onClose (dart-lang/sse#25)
diff --git a/pkgs/sse/CHANGELOG.md b/pkgs/sse/CHANGELOG.md index f320635..0aa832a 100644 --- a/pkgs/sse/CHANGELOG.md +++ b/pkgs/sse/CHANGELOG.md
@@ -1,3 +1,9 @@ +## 3.3.0 + +- Add an `onClose` event to the `SseConnection`. This allows consumers to + listen to this event in lue of `sseConnection.sink.done` as that is not + guaranteed to fire. + ## 3.2.2 - Fix an issue where `keepAlive` may cause state errors when attempting to
diff --git a/pkgs/sse/lib/src/server/sse_handler.dart b/pkgs/sse/lib/src/server/sse_handler.dart index ed4cb9e..e3f6cc7 100644 --- a/pkgs/sse/lib/src/server/sse_handler.dart +++ b/pkgs/sse/lib/src/server/sse_handler.dart
@@ -41,6 +41,11 @@ final _closedCompleter = Completer<void>(); + /// Completes when the [SseConnection] closes. + /// + /// This is guaranteed to fire unlike `this.sink.close`; + Future<void> get onClose => _closedCompleter.future; + /// Creates an [SseConnection] for the supplied [_sink]. /// /// If [keepAlive] is supplied, the connection will remain active for this
diff --git a/pkgs/sse/pubspec.yaml b/pkgs/sse/pubspec.yaml index 8e3ab44..194277d 100644 --- a/pkgs/sse/pubspec.yaml +++ b/pkgs/sse/pubspec.yaml
@@ -1,5 +1,5 @@ name: sse -version: 3.2.2 +version: 3.3.0 homepage: https://github.com/dart-lang/sse description: >- Provides client and server functionality for setting up bi-directional