Skip to content

class's methods declared in background does not show up in foreground!  #2

@amirhouieh

Description

@amirhouieh

I am going to explain the problem by following demonstration:

--------background module

const cpuIntensive = {
      doStuff(){
           let temp = [];
           for(var x=0; x<10; x++)
                temp.push( new MyClass(x) )

          return temp
      }
}

class MyClass{
    constructor(_path){
        this.prop_1=   _path
        this.prop_2 = "/index"
    }
    someMethod() {
        return  this.prop_1+ this.prop_2
    }
}

--------foreground module

const foreground = require('electron-process').foreground;
const test = foreground.getModule(require('./cpuIntensive'));

test.readProfiles()
    .then((data)=>{
        for(var x in data)
            console.log( data[x].someMethod() );
    })
    .catch((reason) => console.error(reason));

error=> TypeError: data[x].someMethod is not a function(…)
althoughdata[x].prop_1 and data[x].prop_2 both are there! I am wonder if this has something to do with the electron-process or for example objectHash?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions