-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Update Stream documentation #17506
base: production
Are you sure you want to change the base?
Update Stream documentation #17506
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one
@@ -15,7 +15,7 @@ The [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) | |||
|
|||
<DirectoryListing /> | |||
|
|||
Workers do not need to prepare an entire response body before delivering it to `event.respondWith()`. You can use [`TransformStream`](/workers/runtime-apis/streams/transformstream/) to stream a response body after sending the front matter (that is, HTTP status line and headers). This allows you to minimize: | |||
Workers do not need to prepare an entire response body before returning a `Response`. You can use [`TransformStream`](/workers/runtime-apis/streams/transformstream/) to stream a response body after sending the front matter (that is, HTTP status line and headers). This allows you to minimize: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@irvinebroque Rereading that paragraph I think "You can use TransformStream
" should actually be "You can use a ReadableStream
"
Note that TransformStream
implements ReadableStream
so the current phrasing is not wrong, just a specialization of the generic case.
I can amend this PR or create a new one.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go for it either way
- Use the module syntax over - TransformStream -> ReadableStream - let -> const where applicable
Summary
Change
event.respondWith(...)
forResponse
.event.respondWith(...)
is the old Service Worker API that is no more recommended.Note that the code snippet on this page is correctly using the Module Worker API.
reference: https://developers.cloudflare.com/workers/runtime-apis/fetch/
Documentation checklist