I am trying to create a desktop application using Electron. My requirement is to use Angular for front-end and python for back-end (that should communicate with SQLite database).
This is what I have ready:
- I have the front-end web application created/designed by Angular 7 and Material
- I also have 10 pure python files (without any framework) that should do some back-end logic whenever buttons are clicked from the web application.
- Electron environment is ready and main.js is pointing to Angular index.html file.
- Python files are in a separate folder not connected to anything yet.
When I fire up the Electron, the app starts and I can see the Angular web interface. All I have left to do is to send the requests when the button is clicked to the backend (python files).
What I know and have tried so far:
- Add ngx-electron module to my Angular component
import { ElectronService } from "ngx-electron"
- I use
ipcRenderer.send('aaa', data)
to send data andipcRenderer.on('bbb', () => {})
to get the response from a MAIN process In the MAIN process (main.js),
ipcMain.on('aaa', (e, filename) => { // exec(pythonfile params); e.sender('bbb', response); })
Questions:
Is this the right way or there is a cleaner solution to send and receive data between Angular and python?
I feel like when you have lots of requests those listeners will become messy, not sure. I have always used HTTP requests that are cleaner but never used inter-process communication ...