JasonDavis
JasonDavis

Reputation: 48933

ElectronJS app to load plugins as separate processes

I am building an ElectronJS desktop app that will look similar to the image below with a sidebar of tools to click on and a right panel to load them into.

I want each tool to be a plugin so I can easily create/add/remove tools from the app

When clicking a tool in the sidebar it will load the plugins settings and files and run functions to build the content on the right.

Ass some plugins will be large apps I do not want to load them all and bogg down memory.

Is there a way to load each plugin tool in the right panel as its own process and then terminate the process and release memory used by that plugin once a new plugin tool is clicked on and loaded into the content panel

enter image description here

Upvotes: 1

Views: 98

Answers (1)

Dany Gagnon
Dany Gagnon

Reputation: 112

You can create a worker with electron-worker and use it whenever you click on one of the tabs.

You can create a new BrowserWindow with the show option to false. It will then act as a new process. Link to the article

You can use the ipcRenderer to contact the ipcMain to then fork a plugin. See Node.js fork

Useful electron article

See Multithreading in electron if performance is a issue.

FYI Differences between process and a thread

Upvotes: 1

Related Questions