[sensors] When there are multiple sensors of a given type, how do we identify which one to instantiate?

tobie has just created a new issue for https://github.com/w3c/sensors:

== When there are multiple sensors of a given type, how do we identify
 which one to instantiate? ==
In #8 we agreed that sensors shouldn't be singletons because it was 
both useful to allow multiple instances of each sensor and necessary 
to support multiple sensor of a given type on a single device (think 
for example proximity sensors on a car).

Imagine we want to check the presence of an object on the back of a 
car, we'll need to get data from one of the back sensors, right?

Should we go with a generic system, taking a DOMString, that would be 
defined in this spec, so for example:

```js
new Sensor.Proximity({ identifier: "back-right" });
new Sensor.Temperature({ identifier: "internal" });
```

…or should we let specs for concrete sensors implement that the way 
they want? So we might get something like (trading off consistency for
 context):

```js
new Sensor.Proximity({ position: "back-right" });
new Sensor.Temperature({ id: "internal" });
```

Questions: 

* Is such an identifier the right solution?
* Should we favor consistency or context?
* What happens when no identifier is passed to the constructor? Must 
there be a default sensor for each type so that you can do: `new 
Sensor.Geoloc()` and not `new Sensor.Geoloc({ identifier: "default" 
})`?
* Where are those lists of sensors defined? In the concrete specs 
themselves? Through an API the consumer can query (e.g. 
`Sensor.Proximity.getAll()`)?


See https://github.com/w3c/sensors/issues/26

Received on Friday, 5 June 2015 10:38:56 UTC