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

Update Stream documentation #17506

Open
wants to merge 1 commit into
base: production
Choose a base branch
from
Open

Update Stream documentation #17506

wants to merge 1 commit into from

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Oct 14, 2024

Summary

Change event.respondWith(...) for Response.

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

Copy link
Contributor

@irvinebroque irvinebroque left a 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:
Copy link
Contributor Author

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?

Copy link
Contributor

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

@vicb vicb changed the title Update index.mdx to use the module syntax Update Stream documentation Oct 14, 2024
- Use the module syntax over
- TransformStream -> ReadableStream
- let -> const where applicable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:workers Related to Workers product size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants