Re: [Web MIDI API] Examples and a serializer

On Sun, Dec 16, 2012 at 1:13 AM, Marcos Caceres <marcosscaceres@gmail.com>wrote:

> In "Getting Access to the MIDI System" and in "A Simple Loopback", it
> would be better if you just wrapped the code in a self invoking function.
> That way, you can avoid the whole discussion about avoiding globals:
>
> (function(){
> …example here...
> }());
>
> Also, please don't use if statements without curly braces… yes, it's part
> of JS, but every style guide recommends against doing this. It means code
> won't lint and can also lead to unforeseen errors.
>

Well, there are style guides for pretty much every imaginable way of doing
things... :D But I agree, if it goes to another line, wrap it in braces.


> Lastly, the "Enumerating Inputs and Outputs" example makes a strong use
> case for adding either a serializer [1] to the MIDIPort interface. It would
> be nice if the object serialized into a JSON compatible structure (i.e.,
> add toJSON compatibility). I think all that needs to be added to MIDIPort
> is:
>
> serializer = { id, manufacturer, name, type, version};
>

I'm pretty sure that conflicts with our current idea of how to add worker
support, i.e. making MIDI ports copyable / transferable via sendMessage(),
since if we added a serializer, sendMessage() would accept MIDIPorts
already, converting them to JSON objects, right?

Cheers,
Jussi

Received on Monday, 17 December 2012 16:15:27 UTC