Skip to content

Commit e9365c2

Browse files
authored
Mention ready in the docs for connect (dart-archive/web_socket_channel#287)
Closes dart-lang/web_socket_channel#280 There can be confusion when there are errors creating the channel because the only wait to catch them is to include an `await channel.ready` in the try block. Mention that `ready` can complete as an error in the case of connection failure.
1 parent 7746475 commit e9365c2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

pkgs/web_socket_channel/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
## 2.4.1
1+
## 2.4.1-wip
22

33
- Update the examples to use `WebSocketChannel.ready` and clarify that
44
`WebSocketChannel.ready` should be awaited before sending data over the
55
`WebSocketChannel`.
6+
- Mention `ready` in the docs for `connect`.
67

78
## 2.4.0
89

pkgs/web_socket_channel/lib/src/channel.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ class WebSocketChannel extends StreamChannelMixin {
134134
/// communicate over the resulting socket.
135135
///
136136
/// The optional [protocols] parameter is the same as `WebSocket.connect`.
137+
///
138+
/// A WebSocketChannel is returned synchronously, however the connection is
139+
/// not established synchronously.
140+
/// The [ready] future will complete after the channel is connected.
141+
/// If there are errors creating the connection the [ready] future will
142+
/// complete with an error.
137143
factory WebSocketChannel.connect(Uri uri, {Iterable<String>? protocols}) =>
138144
platform.connect(uri, protocols: protocols);
139145
}

pkgs/web_socket_channel/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: web_socket_channel
2-
version: 2.4.1
2+
version: 2.4.1-wip
33

44
description: >-
55
StreamChannel wrappers for WebSockets. Provides a cross-platform

0 commit comments

Comments
 (0)