function sendUpdateTableModelEvents() {
count++;
x = x + 1;
if (x === columnCount) {
x = 0;
y = y + 1;
if (y === rowCount) {
y = 0;
val = val===1 ? -1 : 1;
oddTick = !oddTick;
}
}
if (count > 120) {
const now = Date.now();
const deltaTime = now - lastTick;
eleOut.innerText = `${Math.round(10*count / deltaTime * 1000)/10} fps`;
lastTick = now;
count = 0;
}
const cssClasses = {
'bg-green-0': val === 1 && !oddTick,
'bg-green-1': val === 1 && oddTick,
'bg-red-0': val === -1 && !oddTick,
'bg-red-1': val === -1 && oddTick,
};
tableApi.updateCells([new TableCellUpdateEvent('body', y, x, val, cssClasses)]); // <- sending update event
requestAnimationFrame(() => sendUpdateTableModelEvents());
}