I’m building a javascript application that does continuous drawing, but relies on asynchronous scripts in the background which also need to poll for events and write to “global variables”. This got me to start using Workers, but they can’t access my global variables consistently. I was thinking of using Singletons to communicate between the two, allowing my draw loop to keep running while my workers do the heavy lifting.
Theoretically this seems to work, but since workers are designed to operate more functionally is there a better approach?
More info if needed:
Essentially, I’m polling for keyboard interrupts similar to how operating systems register interrupts to programs. Because of scripts created/compiled/stored remotely, scripts are being inserted on the fly with Ensure and run by workers, but they still need to access my global variables my draw loop uses.
5