Re: [sensors] Don't allocate response objects to avoid triggering GC

If sensor has `reading` property, which is an object, with properties,
 then developer in event might assume it is immutable and/or 
instanced. This could lead to confusion like:

var lastReading = null;
accelerometer.onchange = function(reading) {
    if (lastReading) {
        var deltaX = reading.x - lastReading.x;
    lastReading = reading;
Someone would be confused why this wouldn't work on assumption that 
reading was immutable objects.

But if there is no object involved, such as `sensor.x`, then:
var lastX = null;
accelerometer.onchange = function() {
    if (lastX !== null) {
        var deltaX = this.x - lastX;
    lastX = this.x;

There is much less chance to get confused in this case.

GitHub Notification of comment by Maksims
Please view or discuss this issue at using
 your GitHub account

Received on Wednesday, 7 December 2016 12:37:37 UTC