Closed lnrdnl closed 9 months ago
Hello! Thanks for using Vutron
template!
Thank you for reporting the issue. That's a very good point! I hadn't thought about disabling the event listener in the past template code because there was only one screen.
I've fixed and committed the issue to the latest master code, which now uses sendSync
to get the value immediately from the main process instead of going through two steps, and changed the event listener to not register.
Let me know if this doesn't work for you. If you have any other issues or want to leave a comment, please create a new issue and I'll close this one.
Thanks again for reporting the issue!
I suggest using .invoke() here and in IPC use .handle().
Still I'm wondering where to register the listeners if I would have any.
So what I do in onMounted is:
onMounted((): void => {
// Get application version from package.json version string (Using IPC communication)
window.mainApi.invoke('msgRequestGetVersion').then((version: string) => {
appVersion.value = version
})
})
and in IPCs:
// Get application version
ipcMain.handle('msgRequestGetVersion', () => {
return Constants.APP_VERSION
})
MaxListenersExceededWarning In the template a listener for msgReceivedVersion is registered. But this happens every time the component is mounted. So when switching from screen to screen 12 times, you'll get a warning. This is a possible memory leak.
To Reproduce Switch from Main to Second at least 12 times.
Expected behavior Listeners should be registered only once or destroyed on onUnmounted() (I guess)
Device information (please complete the following information):