4 ms·
> Instead, it's much better to use the main node process to handle all exclusive USB access, and then push state to renderers using IPC. You should absolutely
by anaisbetts 7y ago
> Instead, it's much better to use the main node process to handle all exclusive USB access, and then push state to renderers using IPC.
You should absolutely not do this - don't do anything in the main process at all; blocking it even a little bit makes your entire app janky and hang'y. If you want to connect to USB hardware in an isolated context, create a hidden renderer process (aka a BrowserWindow that you don't call `show` on), though tbh I would just use your existing BrowserWindow, I'm not sure why you immediately dismiss it as "poor design".
- semireg 7y agoYou’re assuming the USB read and writes block, but they are in fact async and work quite well for this purpose. My app is document-based so the user may have multiple label designs open. Because of this, USB is handled from a central location. That could be another renderer, but then you have to shuttle data from renderer to renderer (via main) which in and of itself becomes laborious.