You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, is there a way to unsubscribe from an event?
Let's say, I have the following methods
// ipcs.tsexportconst{
ipcMain,
ipcRenderer,
exposeApiToGlobalWindow
}=createInterprocess({main: {asyncdoSomething(){console.log('some logic here and call window');constmainWindow=BrowserWindow.getAllWindows().find(window=>window.title==='[main]');if(mainWindow){ipcMain.invoke.sendToWindow(mainWindow,`here's the data`);}}},renderer: {asyncsendToWindow(_,data: string){console.log('incoming data',data);}},});
// renderer.tswindow.api.handle.sendToWindow(async()=>{console.log('this is second handler');window.api.remove.sendToWindow();})window.api.invoke.doSomething();setTimeout(()=>{window.api.invoke.doSomething();},5000)
When it runs, the first callback suppose to remove sendToWindow and then after 5 seconds, it should pop an error says, there's no handler available but it doesn't. Because the latest event handler window.api.handle.sendToWindow(async () => { }); has been registered in memory.
I believe this can also cause memory leak issue.
Can a handle call window.api.handle.sendToWindow(async () => {}); return a function to unsubscribe itself later on?
The text was updated successfully, but these errors were encountered:
@seahindeniz I think I get it! If I remove the handler from the main process and try to invoke it from the renderer, I get the expected throw behavior, but if I remove the handler from the renderer process and try to invoke it from the main, it doesn't throw as expected! I'll investigate!
Hi, is there a way to unsubscribe from an event?
Let's say, I have the following methods
When it runs, the first callback suppose to remove
sendToWindow
and then after 5 seconds, it should pop an error says, there's no handler available but it doesn't. Because the latest event handlerwindow.api.handle.sendToWindow(async () => { });
has been registered in memory.I believe this can also cause memory leak issue.
Can a handle call
window.api.handle.sendToWindow(async () => {});
return a function to unsubscribe itself later on?The text was updated successfully, but these errors were encountered: