Skip to content

Commit

Permalink
[fix] fix analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Dec 22, 2023
1 parent 3436cd9 commit ac77bb2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/src/_web_socket_connect/_web_socket_connect_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@ import 'dart:js_interop';

import 'package:web/helpers.dart';

// TODO: remove when https://github.com/dart-lang/web/commit/4cb5811ed06
// TODO(mytja): remove when https://github.com/dart-lang/web/commit/4cb5811ed06
// is in a published release and the min constraint on pkg:web is updated
/// [WebSocketEvents] is an extension to the main [WebSocket] class from
/// package:web. It adds appropriate streams while https://github.com/dart-lang/web/commit/4cb5811ed06
/// is not yet published.
extension WebSocketEvents on WebSocket {
/// [onOpen] is a [Stream], which returns [Event]s upon
/// establishing new WebSocket connection.
Stream<Event> get onOpen => EventStreamProviders.openEvent.forTarget(this);

/// [onMessage] is a [Stream], which returns [MessageEvent]s upon
/// receiving messages through the WebSocket connection.
Stream<MessageEvent> get onMessage =>
EventStreamProviders.messageEvent.forTarget(this);

/// [onClose] is a [Stream], which returns [CloseEvent]s upon
/// WebSocket closure.
Stream<CloseEvent> get onClose =>
EventStreamProviders.closeEvent.forTarget(this);

/// [onError] is a [Stream], which returns [Event]s upon error.
Stream<Event> get onError =>
EventStreamProviders.errorEventSourceEvent.forTarget(this);
}
Expand Down

0 comments on commit ac77bb2

Please sign in to comment.