medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
439 stars 211 forks source link

Extract form's instance code out from the Enketo Service in webapp #8092

Open latin-panda opened 1 year ago

latin-panda commented 1 year ago

Describe the issue

Currently, webapp can only display one Enketo form at a time; the enketo service is doing form's instance jobs like unloading a form, setup form's buttons, force a form recalculation, etc.

There is a risk of race condition between form instances; for example, the webapp loads a pregnancy form, then loads a pregnancy follow-up form (by changing the URL); the pregnancy form may have a delay and ends up calling the service to unload after the pregnancy follow up was loaded. The unload function has code that affected the pregnancy follow up form.

These race conditions are rare but can still happen. If we fix this, then maintenance and extensibility will be easier.

Describe the improvement you'd like

garethbowen commented 1 year ago

This may be related to https://github.com/medic/cht-core/issues/7462