- From: Joshua Bell <notifications@github.com>
- Date: Fri, 24 Mar 2023 11:23:48 -0700
- To: w3c/editing <editing@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 24 March 2023 18:24:01 UTC
To be pedantic, this _could_ be done with promises _with the addition of another signal_, e.g. an event as @annevk mentions. I think this would be a poor developer experience compared what's being proposed here. Here's what it could look like, just to demonstrate:
```js
navigator.clipboard.write(new ClipboardItem({
'text/html': new Promise(resolve => {
// somehow this event target is scoped to this clipboard item?
// event will only be fired once, even if paste happens again?
some_target.addEventListener('some_event_type', async e => {
// are we the type handler that's actually desired here?
if (e.requestedType === 'text/html') {
// do a bunch of stuff here, probably async
resolve(results);
}
};
}),
/* repeat the above for every supported type, but we'll only ever call resolve() for one Promise */
}));
```
There may be a cleaner way, but IMHO a callback seems much cleaner.
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/417#issuecomment-1483235664
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/editing/issues/417/1483235664@github.com>
Received on Friday, 24 March 2023 18:24:01 UTC