-
Notifications
You must be signed in to change notification settings - Fork 49
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
requestMIDIAccess should vend a Future, and not direct callbacks #49
Comments
Is there already an API to use 'Future' in HTML5? Anyway, in this case, I prefer to pass arguments as a dictionary like File API. e.g., directory Flags {
boolean systemExclusive;
};
partial interface Navigator {
Future requestMIDIAccess (optional Flags request);
}; Currently, there is another concern about MIDIPort.id as issue 48; #48 . If we should disguise MIDIPort attributes, name, manufacturer, and so on, we may want to add some arguments here to get raw attributes. e,g, directory Flags {
boolean systemExclusive;
boolean portName;
boolean portManufacturer;
}; |
@toyoshim Futures are defined here: http://dom.spec.whatwg.org/#futures |
As I've not actually USED futures before, I wanted to try to see how this would work. I understand the value and use of futures in the abstract sense in more complex async programming, I think, but I'm quite concerned about the usage of futures here keeping MIDI implementation held back until futures are broadly implemented (and understood by developers), unless there's a solid reason for using them. I can't tell if this just "we should do all things in this model from now on." I think the usage of this would look like: requestMIDIAccess( sysexFlag ).done( successFunc, failFunc ); But I don't see a ton of value (and I do see added complexity) over requestMIDIAccess( successFunc, failFunc, sysexFlag ); In a situation where multiple async calls are in play, and there are multiple lifetimes of asynchronous calls that overlap (and interleave) in potentially "interesting" ways, I see the value of the futures pattern. With Web MIDI, the requestMIDIAccess call is asynchronous purely to enable user prompting; and requestMIDIAccess is likely called once, on loading of the page, and the object obtained is kept for the lifetime of the page. Can someone enlighten me? Marcos, Anne, Alex? |
I see added value and reduced complexity in just the reduced number of arguments required for requestMIDIAccess. :) As small part of the complexity is defined in our spec, the happier I feel about it. That said, I'd like to know whether there is a common plan to normalize asynchronous APIs to use Futures. If that's not the case, let's not jump into this, but if it is, SGTM. |
This doesn't really "reduce complexity". The same parameters need to be I've dug into this with Alex a bit more; there is certainly a large On Sun, Apr 28, 2013 at 9:49 AM, Jussi Kalliokoski <[email protected]
|
I'm happy with either, fwiw. |
Actually, the thing is that we can't anticipate how the API will be used together with other APIs, and I doubt that there won't be cases where the MIDI access request runs in parallel with other asynchronous operations so I believe going with something that offers consistence for asynchronous operations definitely has value. I'm leaning towards vending a future. :) |
I definitely want to vend a future, the question I have remaining is On Wed, May 1, 2013 at 10:25 AM, Jussi Kalliokoski <[email protected]
|
Maybe. But generally speaking, I think giving developers many ways to do the same thing probably won't avoid confusion, quite the contrary. :) |
Developers don't read the IDL. They read the sample code. :) On Wed, May 1, 2013 at 10:36 AM, Jussi Kalliokoski <[email protected]
|
Then why bother adding a redundant & non-recommended way of doing things? |
OK, well - my co-editor says change to futures, no one else has complained On Wed, May 1, 2013 at 10:43 AM, Jussi Kalliokoski <[email protected]
|
IDL: Usage: requestMIDIAccess().done( success, failure ); |
Great!
Do dictionaries work like this (I assume you meant sysexRequired to be a boolean)? I thought it would be either:
or
|
Work like the second one. |
The first one doesn't work at all? Good to know, I saw it in the old getUserMedia examples, like |
getUserMedia used to (in Chrome?) work differently, and not follow the On Wed, May 1, 2013 at 11:10 AM, Jussi Kalliokoski <[email protected]
|
@jussi-kalliokoski yeah, that shouldn't work... that's pretty ugly if it does. I like the use of the option as it makes the code easy to understand.... and you can do { sysexRequired: "hell yeah!" } if you are feeling kinda badass. |
Fixed: 78ae07b. |
LGTM, aside from the slip there. \o/ |
As per Alex and Anne's feedback (http://lists.w3.org/Archives/Public/public-audio/2013AprJun/0176.html):
requestMidiAccess can (should?) be re-worked to vend a Future. A cleaned up
interface for it might be:
The text was updated successfully, but these errors were encountered: