Re: Network Information API

Hi Francesco,

On 15/01/2014, at 01:05, Francesco Iovine <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.

> 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.

Thanks for the feedback.

Cheers,

/ Fernando

Received on Wednesday, 15 January 2014 12:05:58 UTC