From 4cb5811ed06ada91f713cf0c26b6c1a76c44b2d7 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 22 Nov 2023 11:18:10 -0800 Subject: [PATCH] Add event extensions for `WebSocket` (#102) Cleanup SDK constraint now that Dart 3.2 is stable Drop lints that were deprecated in Dart 3.3 --- CHANGELOG.md | 2 ++ analysis_options.yaml | 2 -- lib/src/helpers/events/events.dart | 10 ++++++++++ pubspec.yaml | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d50b6ef0..4c432d64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.4.1-wip - Add an example. +- `helpers.dart`: + - Added event extensions for `WebSocket` ## 0.4.0 diff --git a/analysis_options.yaml b/analysis_options.yaml index 90e0df9b..488ec284 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,8 +18,6 @@ linter: - avoid_bool_literals_in_conditional_expressions - avoid_private_typedef_functions - avoid_redundant_argument_values - - avoid_returning_null - - avoid_returning_null_for_future - avoid_returning_this - avoid_unused_constructor_parameters - cancel_subscriptions diff --git a/lib/src/helpers/events/events.dart b/lib/src/helpers/events/events.dart index d6e7e300..41d9783b 100644 --- a/lib/src/helpers/events/events.dart +++ b/lib/src/helpers/events/events.dart @@ -289,3 +289,13 @@ extension WindowCustomEvents on Window { Stream get onTransitionEnd => CustomEventProviders.transitionEndEvent.forTarget(this); } + +extension WebSocketEvents on WebSocket { + Stream get onOpen => EventStreamProviders.openEvent.forTarget(this); + Stream get onMessage => + EventStreamProviders.messageEvent.forTarget(this); + Stream get onClose => + EventStreamProviders.closeEvent.forTarget(this); + Stream get onError => + EventStreamProviders.errorEventSourceEvent.forTarget(this); +} diff --git a/pubspec.yaml b/pubspec.yaml index a6add16b..e4f0bc6f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ version: 0.4.1-wip repository: https://github.com/dart-lang/web environment: - sdk: ">=3.2.0-194.0.dev <4.0.0" + sdk: ^3.2.0 dev_dependencies: analyzer: ^6.2.0