W3C home > Mailing lists > Public > public-device-apis@w3.org > October 2009

Re: What does it all hang off of?

From: Brian LeRoux <brian@westcoastlogic.com>
Date: Fri, 2 Oct 2009 14:43:09 -0700
Message-ID: <a4bcf6320910021443t2273adf2ma342dd76ba2470e3@mail.gmail.com>
To: "Tran, Dzung D" <dzung.d.tran@intel.com>
Cc: Robin Berjon <robin@berjon.com>, "public-device-apis@w3.org" <public-device-apis@w3.org>
my vote would be to keep things simple and consistent. there is
nothing really wrong w/ hanging off of navigator / this is how we
implemented in PhoneGap

On Fri, Oct 2, 2009 at 10:46 AM, Tran, Dzung D <dzung.d.tran@intel.com> wrote:
> My opinion about this issue: it should hang off of navigator.platform or better yet: just platform. Hanging it off of navigator implies that Contacts actually are associated with the browser, which they are not. They are associated with the platform.
>
> Hence, platform.contacts.findOne().
>
> My second choice would be to hang contacts off of device, like #4 below.
>
> -----Original Message-----
> From: public-device-apis-request@w3.org [mailto:public-device-apis-request@w3.org] On Behalf Of Robin Berjon
> Sent: Friday, October 02, 2009 05:33 AM
> To: public-device-apis@w3.org
> Subject: What does it all hang off of?
>
> Hi all,
>
> one issue we have with APIs is also how they are exposed. Say for
> instance that the Contacts API has a basic interface providing access
> to the rest of the functionality called "Contacts". We could:
>
> 1) Make it available as a constructor:
>
>   var cs = new Contacts();
>   var mum = cs.findOne({ nickname: "mum" });
>
> This pollutes the global namespace (since "Contacts" is now a variable
> in that scope), and is useless since there's no use for multiple
> instantiation of that class.
>
> 2) Make it available as an object already instantiated in the global
> scope:
>
>   var mum = contacts.findOne({ nickname: "mum" });
>
> This is nicer, less useless, but still polluting. Given the number of
> APIs that we have, it's probably a bad idea.
>
> 3) Make a way of requesting that an API be "loaded":
>
>   var mum = loadAPI("contacts").findOne({ nickname: "mum" });
>
> This adds only one item to the global scope (which is acceptable), but
> isn't idiomatic.
>
> 4) Use an object to provide access to all the device APIs:
>
>   var mum = device.contacts.findOne({ nickname: "mum" });
>
> I think the latter is the cleanest option. Specifying one such
> extensible object is trivial, and would be a very short specification.
>
> Another option is to hang off of the navigator object just like
> geolocation did - but that seems wrong (I'm not sure why it was chosen
> there).
>
> Thoughts?
>
> --
> Robin Berjon - http://berjon.com/
>
>
>
>
>
>
Received on Friday, 2 October 2009 21:43:45 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:53:39 UTC