blackberry-webworks / BB10-Webworks-API

An api repository for webworks
6 stars 1 forks source link

As a WebWorks developer, I can find out what type of connection my application is currently using #23

Closed kwallis closed 11 years ago

kwallis commented 12 years ago

Acceptance Criteria

  1. This api should return information such as WiFi versus cellular, etc.
  2. API should be in line with the Cordova Connection API
  3. Use the blackberry.connection feature id
  4. Contains the blackberry.connection.type property that contains the required information
  5. Proposed values: Connection.UNKNOWN Connection.ETHERNET Connection.WIFI Connection.CELL_2G Connection.CELL_3G Connection.CELL_4G Connection.NONE
nukulb commented 12 years ago

perhaps an actual event when type changes would be just as useful, applications might want to warn the user that they are now not on Wifi etc.. if they are streaming music or videos.

w3c or cordova both do not have anything like this, but it seems useful to me. @kwallis - let me know what you think.

rwmtse commented 12 years ago

There is a technical difficulty in following the Cordova API (i.e. making that information available in blackberry.connection.type property).

The expected behavior is supposed to be: whenever the field is accessed, a call will be made to the native side to find out what's the current active connection interface, correct?

But since in BB10 we are building the blackberry object on page load, all the values of the properties will be cached once it's loaded, i.e. once the page is loaded, the connection type value that gets returned will always be that cached value. Unless it is ok to return the cached value, otherwise this information must be returned via a function, not a property.

rcruz commented 12 years ago

Can we use something like defineGetter to run a function when the property is accessed?

rwmtse commented 12 years ago

Problem solved: http://ejohn.org/blog/ecmascript-5-objects-and-properties/