- From: Greg Billock <gbillock@google.com>
- Date: Wed, 28 Mar 2012 16:50:17 -0700
- To: WebIntents <public-web-intents@w3.org>
Hi everyone! I'll be sending several emails in the next few days following up to discussions we had at the F2F meeting. One proposal is adding an object literal constructor for the Intent object. This object literal will be convenient for adding other types of constructor arguments which we know we will want (defaults, explicit intents, perhaps even more exotic varieties to be discovered later). My proposal is to replace the existing signature with the object literal constructor. Current: [Constructor(in string action, in string type, in optional any data, in optional sequence<Transferable> transferList, in optional dictionary<string> extraData) raises DOMException] interface Intent { readonly attribute DOMString action; readonly attribute DOMString type; readonly attribute any data; readonly attribute MessagePort[] ports; string getExtra (DOMString key); void postResult (any data, optional sequence); void postFailure (any data); }; Proposed change: dictionary IntentParameters { DOMString action; DOMString type; any data; sequence<Transferable> transfer; dictionary<string> extras; } [Constructor(in IntentParameters parameters)] interface Intent { readonly attribute DOMString action; readonly attribute DOMString type; readonly attribute any data; readonly attribute MessagePort[] ports; string getExtra (DOMString key); void postResult (any data, optional sequence); void postFailure (any data); }; When using the object literal constructor, the "action" and "type" members are required, all others are optional. (Aside to Robin: is there a convention for marking required/optional dictionary fields? I saw a "type? name" syntax on IndexedDB. Is that the standard?) The proposal removes the constructor without the object literal: [Constructor(in string action, in string type, in optional any data, in optional sequence<Transferable> transferList) raises DOMException] What do you think? Would it be an advantage to keep this constructor to keep the simple use cases simpler? The difference is this: var x = new Intent("http://webintents.org/view", "schema.org/Person", person); vs var x = new Intent({"action":"http://webintents.org/view", "type":"schema.org/Person", "data":person}); Is the shorter first form worth the addition of the extra constructor signature? Named arguments are pretty nice...
Received on Wednesday, 28 March 2012 23:50:46 UTC