Re: [whatwg/fetch] Feed a Response to existing APIs (#49)

Coming back to this years later.

First off, I think we should design our solution to accept:

- `Request`
- `Promise<Response>`
- Maybe any `BodyInit`, including `ReadableStream`, if we can figure out some default headers. (Note that `Blob` is already accepted by `HTMLMediaElement`.)

> Cannot allow e.g. `Promise<Response>` since promises are not distinguishable from other types

This note was a bit unclear to me. I think it was talking about existing `srcObject` properties: i.e., we couldn't do `(MediaStream or Media or Blob or Promise<Response>)` for `HTMLMediaElement`'s `srcObject`. This is true, especially because of the getter, which currently synchronously returns the value it was set to.

I see a few solutions:

- Change IDL to support separate getter/setter types, and change the setter to accept `Promise<... all the things ...>` while the getter returns null while the promise is resolving and returns the actual object once it's given
- Choose a different property name, e.g. `srcResponse`, and use that everywhere.
- Choose a different API shape, e.g. one without a troublesome getter, like `load()` or `loadFromResponse()` or similar.

I lean toward the last one, to be honest. Any thoughts?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/49#issuecomment-441783970

Received on Monday, 26 November 2018 20:21:28 UTC