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

Add examples for stopping pipes #1059

Merged
merged 1 commit into from Jul 27, 2020
Merged

Add examples for stopping pipes #1059

merged 1 commit into from Jul 27, 2020

Conversation

domenic
Copy link
Member

@domenic domenic commented Jul 23, 2020

Closes #1055.


Preview | Diff

Copy link
Collaborator

@ricea ricea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

controller.abort();
</xmp>

(The above omits error handling for the promise returned by {{ReadableStream/pipeTo()}}.
Copy link
Collaborator

@ricea ricea Jul 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two sentences inside "()" looks a little odd to me. I think you could just omit the "()" characters here without changing the meaning too much. If you like. I don't have really strong feelings about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, on balance I like it, as a way of deemphasizing these sentences. I'll keep it. Thanks for weighing in though.

@domenic domenic merged commit 505edd7 into master Jul 27, 2020
@domenic domenic deleted the abortsignal-example branch July 27, 2020 17:12
@domenic
Copy link
Member Author

domenic commented Aug 17, 2020

FYI folks might be interested in the discussion I'm having over in whatwg/dom#881 on making this pattern less terrible.

@domenic
Copy link
Member Author

domenic commented Aug 17, 2020

Hmm, or we could do something entirely on the Streams side. For example:

const controller = new AbortController();
readable1.pipeTo(writable, { preventAbort: true, signal: controller.signal });

// ... some time later ...
controller.abort();

// Start the new pipe, when ready:
readable2.pipeTo(writable, { waitForPrevious: true });

with the same semantics. (That would require storing the previous pipe promise while it is not settled, but that seems OK.)

I don't think we could make waitForPrevious the default; my intuition is that that would transform too many error cases into stalled cases. But maybe it'd work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Possible to undo .pipeTo()?
3 participants