Skip to content

Commit

Permalink
Mention ready in the docs for connect (#287)
Browse files Browse the repository at this point in the history
Closes #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.
  • Loading branch information
natebosch authored Oct 6, 2023
1 parent 364013d commit f3ac1bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 2.4.1
## 2.4.1-wip

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

## 2.4.0

Expand Down
6 changes: 6 additions & 0 deletions lib/src/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ class WebSocketChannel extends StreamChannelMixin {
/// communicate over the resulting socket.
///
/// The optional [protocols] parameter is the same as `WebSocket.connect`.
///
/// A WebSocketChannel is returned synchronously, however the connection is
/// not established synchronously.
/// The [ready] future will complete after the channel is connected.
/// If there are errors creating the connection the [ready] future will
/// complete with an error.
factory WebSocketChannel.connect(Uri uri, {Iterable<String>? protocols}) =>
platform.connect(uri, protocols: protocols);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: web_socket_channel
version: 2.4.1
version: 2.4.1-wip

description: >-
StreamChannel wrappers for WebSockets. Provides a cross-platform
Expand Down

0 comments on commit f3ac1bf

Please sign in to comment.