joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
755 stars 141 forks source link

Main thread not receiving message #115

Open morganruffner opened 4 years ago

morganruffner commented 4 years ago

I was able to get the worker thread to receive a message, but when it then calls self.postMessage it does not seem like the main thread is receiving it. I have declared the thread with:

mettimer = new Thread('./cameraworker.js'); mettimer.onMessage = this.handleMessage;

where handleMessage is:

handleMessage = message => { console.log('recieved message'); }

In the worker file I have:

self.onmessage = (message) => {

console.log('message received'); self.postMessage(' ');

}

Am I missing something or is this a problem with the module?

PotrusKaterina commented 4 years ago

I have the same. Ive found, that message can be canceled because thread is null. I deleted this *if*, but it still doesnt work(

backmeupplz commented 3 years ago

Try changing onMessage to onmessage