W3C home > Mailing lists > Public > public-device-apis@w3.org > June 2015

Re: [sensors] Do we need a lightweight interface representing available sensors?

From: Tobie Langel via GitHub <sysbot+gh@w3.org>
Date: Mon, 08 Jun 2015 16:56:13 +0000
To: public-device-apis@w3.org
Message-ID: <issue_comment.created-110072591-1433782573-sysbot+gh@w3.org>
@domenic outside of the various issues you mentioned above, how does 
the overall approach sound?

You'd do something like:

```js
Sensor.getAll({ type: "proximity" }).then(function(sensors) {
    return sensors.filter(function(s) {
        return s.direction == "front" && s.position == "top";
    }).map(function(s) {
        var prox = new Sensor.Proximity({ identifier: s.identifier, 
frequency: 60 /* etc… */ });
        // or smthing like: new SensorObserver.Proximity(etc...);
        prox.onchange = dostuff;
        return prox;
    }); 
});
```

-- 
GitHub Notif of comment by tobie
See https://github.com/w3c/sensors/issues/28#issuecomment-110072591
Received on Monday, 8 June 2015 16:56:15 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:54:05 UTC