I have data coming in every second from a Web Socket eg
1- [["X",1],["Y",2],["Z",3]]
2 -[["X",2],["Y",7]]
3 -[["Y",5],["Z",1]]
4 -[["X",7]]
...
The resultant array for each iteration
1 - ["X",1,0],["Y",2,0],["Z",3,0]] // 0 is nothing but the difference it can also be + or minus
2 - ["X",2,1],["Y",7,5],["Z",3,0]] // diff from first iteration
3 - ["X",1,0],["Y",5,-2],["Z",1,-2]] // diff from second
the things i have tried till now
this.socketSubscription = this.socket.messages.subscribe((message) => {
this.prev = this.rows;
this.rows = JSON.parse(message);
if(this.prev){
this.rows.forEach(element => {
for (var index = 0; index < element.length; index++) {
console.log(element[index]);
let check = this.prev.find(prevElement => prevElement.find(el => el[0]));
console.log("check"+check);
/* if (element[0] === ())){
console.log("here");
} */
}
});
}