In an event handler I have a loop which steps through a retool table. This is done like this:
for (let i = 0; i < numvec.value; i++) {
console.log('start row=' + i)
vector_batch.selectRow(i);
//(more stuff happens)
What then happens is that values are pulled from the table, using vector_batch.selectedRow
, to drive the rest of the process. The first step is to output another string to the console.log:
console.log('description=' + vector_batch.selectedRow.data.n_description);
Then some other logic is called (a query) which accesses this same string: vector_batch.selectedRow.data.n_description
.
All this seems to work fine. With each successive iteration of the loop the logic is looking at the next row in the table and vector_batch.selectedRow.data.n_description
is different on each iteration.
However...looking at the console log, the output from:
console.log('description=' + vector_batch.selectedRow.data.n_description);
is correct on the first iteration of the loop but then is stuck there, outputting the same string over and over, as if the expression evaluation has been cached. This could be explained by some (broken) optimization process that does not understand that the value:
vector_batch.selectedRow.data
can be changed by
vector_batch.selectRow(i);
In the parts of the code elsewhere which access vector_batch.selectedRow.data
this failure mode does not seem to appear. But it is especially unwelcome inside console.log because that is where we rely on seeing correct output to really understand what the code is doing.