First I’d like to say that I am aware that the separation of concerns in Electron is something that has been discussed before Electron App Database File Structure/Code Structure . I’m submitting this post out of being personally confused but also because I think clarity on the question would benefit everyone looking to begin with Electron. Also in this post I’m using
renderer, rather than
To my mind this is a common use case which causes confusion regarding how best to separate concerns in an Electron app. As it is a common use case I am hoping it can help guide my efforts to both understand electron and eventually submit some documentation back to the community.
So my request would be some skeleton code that illustrates a best practice. I’ve made a stab of it in the above gist. I’d like to know if this is a a standard pattern for menu functions in electron: all of the code
AFAIK in the above instance writing a separate script for file functionality that employs the remote module doesn’t make sense as everything apart from appending text to a DOM element (
Dialog) is handled by a main module. To my mind there also isn’t the ability to write the openFile() and saveFile() functionality as a separate file on the renderer side – if a js file requires ‘remote’ (as such a file would) it can’t be loaded via
'require ()' until a BrowserWindow exists. The docs make mention of