I'm developing an Electron app with React and Typescript. The logic which the app requires is in the main.ts and passes the object to the renderer via IPC. How I learned does IPC serialize the objects and therefore lose it's functions and prototypes.
Now my question: is there a way to have the same object (with it's type) om the renderer?
I tried with Object.assign()
but this returns the following error:
Uncaught Error: Cannot read properties of undefined (reading 'ReferenceDescription')
By the way I'm using the node-opcua
package which exports the ReferenceDescription class.
My code in the renderer to reassign the object looks like this:
import { ReferenceDescription } from 'node-opcua';
// [...]
window.electron.opcua.onNodeListChange(nodes => {
let typedNode = Object.assign(ReferenceDescription, nodes[0]);
// also tried: new ReferenceDescription()
}
Is there any way to get back the types in the renderer after IPC transfer?