I have the following problem:
I have a Node JS application which should be controlled via Mqtt. It should use the callback function to evaluate messages as to whether the application should start or stop. This already works very well.
However, this application should publish its status every second. However, this should not block the main application. I have already implemented an application that does exactly this in Python. This uses a thread to send the status and does not block the main thread. I need a way to outsource a send state function to a background process.
Since JavaScript only knows single threads, is there a way to enable this?
I’ve already dealt with workers but don’t want to outsource the code to an external file.
thank you