wq/wq.app

Watching for template changes in react environment

simonwinter opened this issue · 2 comments

Is there a recommended approach to watching for template changes in the react version of the app?

Currently the templates are inlined via the update_json.sh script. I'm running my dev environment inside a docker container & have taken to useing inotify-tools to detect template changes & update the templates.json file as necessary.

This seems like a bit of a clunky approach - is there a better way to watch for changes in dev? Or am I doing something wrong here?

There isn't currently a built-in way to handle this, so suggestions are helpful. To be clear, the templates are only needed for the Mustache/jQuery Mobile renderer. In the upcoming React/Material UI implementation, templates.json is not used at all, since the UI is generated directly from the config.json and registered React components. That said, it will still be useful to regenerate config.json whenever the Django models change.

I updated wq.db to automatically regenerate data/config.js whenever runserver reloads - see this commit. I didn't implement the same logic for data/templates.js (which is deprecated), but you could use a similar approach. Basically you would just need to specify a custom Django AppConfig and make sure it calls the appropriate shell commands in ready().