I am building a javascript remote for Kodi, where i only send data if it is changed. I am stuck with this peace of code. It will check every x seconds for a value but i only want to do something if the value has changed. Can someone shed some light on this?
every((0.35).second(), function() {
  var kodi_api_request = {"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1};
  var kodi = encodeURIComponent(JSON.stringify(kodi_api_request));
  var previous = {};
  var stuff = request
  .get('http://localhost:8080/jsonrpc?request=' + kodi, function (error, response, data) {
    var newdata = data
    if (previous !== newdata) {
      console.log('changed');
      previous = newdata;
      console.log(newdata);
    } else {
      console.log('Error!');
    }
  });
});
