Re: Network Information API

On Wednesday, 15 January 2014 at 11:57, Fernando Jiménez Moreno wrote:

> Hi Francesco,
>  
> On 15/01/2014, at 01:05, Francesco Iovine <f.iovine@gmail.com (mailto:f.iovine@gmail.com)> wrote:
> > Hi Fernando,
> >  
> > I have read your proposal, I think it's very well written and comprehensive, very useful to me.
>  
> Thanks! I'm glad you found it useful.
>  
> > What I want to point out here is that, if I didn't miss something, Marcos proposed an alternative API design based on the new NetInfo interface:
> >  
> > http://lists.w3.org/Archives/Public/public-device-apis/2014Jan/0013.html
> >  
> > What I have understood is that the new spec proposed by Marcos provides the following objects/properties:
> >  
> > navigator.netInfo
> > navigator.netInfo.connection
> > navigator.netInfo.connection.type // "wifi", "cellular", "disabled"
> > navigator.netInfo.onconnectionchange
> >  
> > I like this new API design mainly because in this way the API can be easily extended by adding properties to the NetInfo object.
>  
> I had a brief conversation with Marcos about this. He can probably elaborate more on this and of course correct me if I am wrong, but as far as I can tell, his reason for adding the netInfo interface was, as you mentioned, to make it more future proof to changes, mostly wrt the naming of things, like instead of 'onchange' it could be 'onconnectionchange', so if things change in the API in the future it will be more clear to what the change applies. I didn't have an strong opinion about this so we just left it as 'navigator.connection' for now, but I am open to reconsider this. I actually agree that it might make it more future proof to extensions.

Yeah, we can bikeshed the design a bit more later if we manage to get agreement as to wether we want to add this to the platform at all.  Right now, just getting agreement on the use cases (and that the current design actually meets the use cases) would be nice.  
   
> > Also, the new NetInfo object might be useful to distinguish User-Agents implementing the latest spec from User-Agents implementing the specification v1 (2011). Something like:
> >  
> > if (navigator.netInfo) { /* Upcoming W3C spec */
> > }
> > else if (navigator.connection) { /* W3C Working Draft 7 June 2011 */
> > }
>  
>  
> This is also a good point. I wonder how extended is the usage of the v1 of this spec though. If I am not wrong the Android browser and PhoneGap are the only implementors of this API.
>  
I think that's right. I remember Mounir saying that some version of this had shipped on Firefox for Android, but then was removed. So, hopefully no versioning code needed.  

Received on Thursday, 16 January 2014 15:13:17 UTC