Closed axel7083 closed 7 months ago
Hi @axel7083 in the redefined context, the other handler only will be called when you explicitly call it like:
handle.getPing(async (_, { getPing, data }) => {
const response = await getPing(_, data) // here
})
if you don't call it, that handler will serve just for the type safe purpose and only the redefined one will be called!
In other hand, you can try to make it in the interprocess object without the redefinition, but to be able to handle main processes apis without conflict with renderer process in the same file, you must use dynamic imports:
createInterprocess({
main: {
async openDialog() {
const { dialog } = await import('electron')
}
}
I am not sure to fully understand the correct usage of the
interprocess
library.Let's have a situation where your main electron process have some objects instance, for example a
connection
and allow to get some data from a database. Thisconnection
object is created in thesrc/main/index.ts
file inside thecreateWindow
function.Now, I want to create a getData channel, fully typed, however in my
src/shared/ipcs/index.ts
, when I am running thecreateInterprocess
I do not have access to the main objects.On this
desktop
example there is the followinghttps://github.com/daltonmenezes/interprocess/blob/59f63b02fb50b1c42099fdd3b510ef27a4e57053/apps/desktop/src/main/ipc/index.ts#L5-L19
It seems that it is possible to redefine the handler, but what's should the other one return if it is something that should never be used (because no access to the database object) ?