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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## Unreleased
9
9
10
+
## 0.10.0 - 2023-09-28
11
+
10
12
### Added
11
13
14
+
* Added the [`Session#batch`](./docs/api.md#sessionbatch-batcher-eventbuffer--buffer-eventbuffer--void--promisevoid--promisevoid) method that can be used to batch multiple events into a single transmission over the wire.
12
15
* Added the [`EventBuffer`](./docs/api.md#eventbuffer) class that can be used to write raw spec-compliant SSE fields into a text buffer that can be sent directly over the wire.
If given an [`EventBuffer`](#eventbuffer) instance, its contents will be sent to the client.
103
+
104
+
If given a callback, it will be passed an instance of [`EventBuffer`](#eventbuffer) which uses the same serializer and sanitizer as the session.
105
+
Once its execution completes - or once it resolves if it returns a promise - the contents of the passed [`EventBuffer`](#eventbuffer) will be sent to the client.
106
+
107
+
Returns a promise that resolves once all data from the event buffer has been successfully sent to the client.
108
+
98
109
#### `Session#event`: `(type: string) => this`
99
110
100
111
**⚠ DEPRECATED:** This method is deprecated. [See here](https://github.com/MatthewWid/better-sse/issues/52).
@@ -228,8 +239,6 @@ Takes the [same arguments as the Channel class constructor](#new-channel()).
228
239
229
240
An `EventBuffer` allows you to write [raw spec-compliant SSE fields](https://html.spec.whatwg.org/multipage/server-sent-events.html#processField) into a text buffer that can be sent directly over the wire.
230
241
231
-
This is made available for users with more advanced use-cases who need to create an event text stream from scratch themselves. Most users will not need to access this directly and can use the simplified helper methods provided by the [`Session`](#session) class instead.
232
-
233
242
#### `new EventBuffer([options = {}])`
234
243
235
244
`options` is an object with the following properties:
Copy file name to clipboardExpand all lines: src/EventBuffer.ts
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,6 @@ interface EventBufferOptions {
22
22
23
23
/**
24
24
* An `EventBuffer` allows you to write raw spec-compliant SSE fields into a text buffer that can be sent directly over the wire.
25
-
*
26
-
* This is made available for users with more advanced use-cases who need to create an event text stream from scratch themselves. Most users will not need to access this directly and can use the simplified helper methods provided by the `Session` class instead.
27
25
*/
28
26
classEventBuffer{
29
27
privatebuffer="";
@@ -121,7 +119,7 @@ class EventBuffer {
121
119
};
122
120
123
121
/**
124
-
* Create, write and dispatch an event with the given data to the client all at once.
122
+
* Create, write and dispatch an event with the given data all at once.
125
123
*
126
124
* This is equivalent to calling the methods `event`, `id`, `data` and `dispatch` in that order.
127
125
*
@@ -151,7 +149,7 @@ class EventBuffer {
151
149
* If no event name is given in the `options` object, the event name is set to `"stream"`.
152
150
*
153
151
* @param stream - Readable stream to consume data from.
154
-
* @param options - Options to alter how the stream is flushed to the client.
152
+
* @param options - Event name to use for each event created.
155
153
*
156
154
* @returns A promise that resolves or rejects based on the success of the stream write finishing.
0 commit comments