I have two applications, the first reads data from memory and then sends this data to the second application, which always holds an object with the latest data.

Currently, I read all the data in application one and send the complete json object to application 2. To make this more efficient, I'd like to only send what has updated and then in application 2, apply these changes.

I've tried sevaral things over the weekend but I can't decide how to properly do it.

Right now, while reading the data from memory (with a function running every 30ms), I check if the values are different from what they were, just before I read them. If so, put them into an update object or array.

Which currently looks like this:

```
let globalData = {};
let updateList = {};

function readThingsFromMemory() {
  updateList = {};

  for ( ... ) {
    [read memory]
    setData(... , ..., ...);
  }
}

function setData(...1, ...2, ...3) {
  if (globalData[...1][...2] != ...3) {
    if (updateList[...1] === undefined) {
      updateList[...1] = {};
    }
    updateList[...1][...2] = ...3;
  }
  globalData[...1][...2] = ...3;
}

setInterval(() => {
  readThingsFromMemory();

  // Send updateList to application 2 if updateList != empty
}, 30);

```

This just seems to me like a weird way and I feel like this could be a lot cleaner and maybe even easier.

Would it even be a good idea to first, create a globalData object from readThingsFromMemory() and after that, loop over that object and determine the differences? Or is it better to do this while reading the memory?

**Side notes: Using memoryjs to read from memory and using websockets to send the data to application 2. Also note: The data is an object of objects, not just a plain object.**