OK, got it pinned down much more. I actually simplified it too much, and the problem went away, and I had to hunt for the situation that caused it to come back! The real problem is not like I described above (sorry). I have just now learned that the problem is NOT that it does not run the sheetworker when the attribute is ADDED. It is that it does not run an on-change sheetworker if the change is done during an on-sheet-opened sheetworker event! The problem is only seen when you have a function that runs all of your calculations when the sheet is first opened. <!DOCTYPE html>
<meta charset="UTF-8">
<div class="user-root">
<input name="attr_a" type="number" value="1" style="width: 3em;" >
<input name="attr_b" type="number" value="1" style="width: 3em;" >
<input name="attr_c" type="number" value="1" style="width: 3em;" >
<br>
<input name="attr_r1" type="number" value="0" style="width: 3em;" >
<input name="attr_r2" type="number" value="0" style="width: 3em;" >
</div>
<script type="text/worker">
var calculateR1 = function () {
'use strict';
log( "r1");
getAttrs(["a", "b" ], function gar1(values) {
'use strict';
let vals = {};
vals[ "r1"] = parseInt(values[ "a"]) + parseInt( values[ "b"]);
log( "a = " + values["a"]);
log( "b = " + values["b"]);
log( "r1 = " + vals["r1"]);
setAttrs( vals);
});
};
var calculateR2 = function () {
'use strict';
log( "r2");
getAttrs(["c", "r1" ], function gar1(values) {
'use strict';
let vals = {};
vals[ "r2"] = parseInt(values[ "c"]) + parseInt( values[ "r1"]);
log( "c = " + values["c"]);
log( "r1 = " + values["r1"]);
log( "r2 = " + vals["r2"]);
setAttrs( vals);
});
};
on("change:a change:b", function () {
calculateR1();
});
on("change:c change:r1", function () {
calculateR2();
});
on('sheet:opened',function fnOnSheetOpened(){
'use strict';
log( "sheet opened.");
calculateR1();
});
</script>
When the sheet is opened for the first time, it is supposed to do all the calculations. Now I knew that because of asynchronous issues, R1 is not going to be correct if calculateR2 is run while calculateR1 is still being processed. But I trusted that when R1 was actually written out, it would generate the event that would cause calculateR2 to run. It is not. I can't think of how to fix this. calculateR2() can't be in sheet-opened, because it would run before calculateR1 is done, and R1 does not yet have the correct value. But I don't want to have calculateR1 call it directly, because then it would be called twice in every other circumstance!