Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "connection" promise to "opened" #16

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Here’s a basic example of usage of the new API:

```javascript
const wss = new WebSocketStream(url);
const { readable } = await wss.connection;
const { readable } = await wss.opened;
const reader = readable.getReader();
while (true) {
const { value, done } = await reader.read();
Expand Down Expand Up @@ -57,7 +57,7 @@ Writing also uses the backpressure facilities of the Streams API:

```javascript
const wss = new WebSocketStream(url);
const { writable } = await wss.connection;
const { writable } = await wss.opened;
const writer = writable.getWriter();
for await (const message of messages) {
await writer.write(message);
Expand All @@ -70,16 +70,16 @@ the second argument to the WebSocket constructor:

```javascript
const wss = new WebSocketStream(url, {protocols: ['chat', 'chatv2']});
const { protocol } = await wss.connection;
const { protocol } = await wss.opened;
```

The selected protocol is part of the dictionary available via the
`wss.connection` promise, along with “extensions”. All the information about
`wss.opened` promise, along with “extensions”. All the information about
the live connection is provided by this promise, since it is not relevant if the
connection failed.

```javascript
const { readable, writable, protocol, extensions } = await wss.connection;
const { readable, writable, protocol, extensions } = await wss.opened;
```

The information that was available from the onclose and onerror events in the
Expand Down