I have a non-react custom control (
ccPrintInvoice) in a module (
PrintInvoice). I trigger a function inside of
ccPrintInvoice which generates a PDF. Since I cannot call the function directly, I am subscribing to the model to watch any changes.
When it sees
model.begin go high, it runs the function and immediately sets
model.begin low so it does not trigger again.
model.begin is linked to a module input called start and that is linked to the temp var
StartInvoice back in the app.
I am also setting
model.working high while the PDF is being worked on. When done, the function sets
model.url to the PDF's url.
I am using
model as the output to the module.
Back on the app, I watch
model.working using a JSON with SQL query. It then triggers a JS that sets
StartInvoice back to false.
Well, the JSON with SQL query fires constantly even though the watched value has not changed. Also the model subscription continuously fires. If I disable the query, the model subscription also calms down.
I know this is kind involved.
Here is the workflow and screencaps below.
In app, set
startInvoice true. In module this is received by the start input which is tied to
model.begin in the CC (custom component.) The model subscription fires due to the change and sees that
model.begin is true.
model.begin set to false.
model.working set to true and PDF builds.
model.working set to false,
model.url set. In the app JSON query triggers when model.working changes and sets startInvoice to false. This triggers the model subscription in the CC which should ignores it as false.
Module with CC:
App with my query:
My guess as to what is happening. Setting
startInvoice to false of course ends up setting the
model.begin to false which triggers the model subscription. The model subscription checks model and something about that resets the model which then propagates back up and triggers the query watching the model which fires again. Rinse, lather, repeat.