W3C home > Mailing lists > Public > public-device-apis@w3.org > January 2014

Re: Network Information API

From: Marcos Caceres <w3c@marcosc.com>
Date: Thu, 9 Jan 2014 15:00:28 +1000
To: Mats Wichmann <m.wichmann@samsung.com>
Cc: public-device-apis@w3.org
Message-ID: <F2FEDC4A507F4EE08D69BD79C6F4FFD8@marcosc.com>

On Thursday, December 19, 2013 at 1:18 PM, Mats Wichmann wrote:

> As I re-read that last bit it felt like I'm asking a question while
> suggesting some answer is more favored but that's just clumsy wording
> which I don't quite see how to improve, I really just mean to ask the
> question: if the conditions aren't technically perfect to standardize,
> as a W3C project, where do we stand on this kind of dilemma?

I guess where we are now. Trying to figure out if we do anything at all by throwing use cases, data, and citations at each other :)   

I think we’ve gotten to a good place through this process, though. I’d be happy to draft up and alternative API design based on the discussions we’ve had.  

Something like:

interface NetInfo : EventTarget{
   readonly attribute ConnectionType connection;
   readonly attribute onconnectionchange;  

//We can add new types as needed in the future - disabled can be a stand in for “airplane” mode or similar user-controlled network disconnect.  
enum ConnectionType{ “wifi”, “cellular”, “disabled”}

partial interface Navigator{
    readonly attribute NetInfo netInfo;  

Then it’s composable with other APIs  - like battery status, to address Tobie’s use cases of being able to make smarter decisions about when to sync (FWIW, I think having better primitives that devs can work with would be better than deferring all this to the UA - at least initially till we see clear usage patterns):

window.onload = (e) => {
var battery = navigator.battery,
      netInfo = navigator.netInfo;
if(!battery.charging  && netInfo.connection === prefs.preferredSyncConnectionType){
   //do synchronization     

//Stop transferring data when discharging  
battery.addEventListener(“chargingchange”, (e) => {
   if(battery.charging && app.isSyncing){

netInfo.addEventListener(“connectionchange”, (e) =>{
   if(NetInfo.connection === “cellular” && fetchQueue.state === “fetching"){
} );
Received on Thursday, 9 January 2014 05:01:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:33:03 UTC