You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 26, 2023. It is now read-only.
Copy file name to clipboardexpand all lines: README.md
+29
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,14 @@ pipe(conn, muxer, conn) // conn is duplex connection to another peer
105
105
```js
106
106
new Mplex(stream=> { /* ... */ })
107
107
```
108
+
* `onStreamEnd` - A function called when a stream ends.
109
+
```js
110
+
// Get notified when a stream has ended
111
+
const onStreamEnd = stream => {
112
+
// Manage any tracking changes, etc
113
+
}
114
+
constmuxer=newMuxer({ onStreamEnd, ... })
115
+
```
108
116
*`signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) which can be used to abort the muxer, _including_ all of it's multiplexed connections. e.g.
109
117
```js
110
118
constcontroller=newAbortController()
@@ -126,6 +134,16 @@ const muxer = new Muxer()
126
134
muxer.onStream = stream => { /* ... */ }
127
135
```
128
136
137
+
#### `muxer.onStreamEnd`
138
+
139
+
Use this property as an alternative to passing `onStreamEnd` as an option to the `Muxer` constructor.
140
+
141
+
```js
142
+
constmuxer=newMuxer()
143
+
// ...later
144
+
muxer.onStreamEnd=stream=> { /* ... */ }
145
+
```
146
+
129
147
#### `const stream = muxer.newStream([options])`
130
148
131
149
Initiate a new stream with the remote. Returns a [duplex stream](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it).
0 commit comments