[sensors] Add a threshold option

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

== Add a threshold option ==
Johnn-Five implements a [treshold attribute][1] which determines the 
amount of change necessary of the value of the sensor to trigger a 
`change` event. Given we want to support sensors with multiple values,
 we'd at least need to add an attribute for each value. It might be 
simpler to add a method that would compare the current values with the
 last emitted ones and return a boolean (which would be used 
internally to decide whether or nor to trigger the `change` event). So
 for example setting up a geoloc sensor to only trigger when changing 
hemisphere:

```js
new Sensor({
    change: function(prev, curr) {
        return Math.sign(prev.latitude) !== Math.sign(curr.latitude);
    }
});
```

[1]: https://github.com/rwaldron/johnny-five/wiki/Sensor#events

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

Received on Friday, 5 June 2015 10:12:35 UTC