[w3c/clipboard-apis] [Async Clipboard API] Use Stream APIs to provide data during write (Issue #212)

Copied from https://github.com/w3c/editing/issues/423#issuecomment-1858535412.

@saschanaz said:
> Hmm, I was not fully understanding this issue back in the meeting, as my focus was on a different issue. To reiterate what @smaug---- said with some code, can this be:
> 
> ```js
> navigator.clipboard.write(new ClipboardItem({
>   'text/html': new ReadableStream({
>     pull(controller) {
>       // This will only be called when the consumer reads it, so this is still about "have callback".
>       controller.enqueue(bytes);
>     },
>     type: "bytes",
>   }, { highWaterMark: 0 }),
> }));
> ```
> 
> I think this can coexist with callback, though.

@smaug---- said
> Using a stream could let implementations to optimize memory usage, as an example.

I think this could be a good addition in general to the async clipboard APIs, so creating this issue for further discussions.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/212
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/issues/212@github.com>

Received on Friday, 9 February 2024 17:40:43 UTC