devfd/react-native-workers

Error downloading web worker

jitenderchand1 opened this issue ยท 6 comments

I have worker script in same folder in which I have a file in which I am worker js.

//service.js
const worker = new Worker('worker.js');

Both service.js and worker.js is in same folder.

screen shot 2016-09-27 at 5 09 29 pm

@jitenderchand1 Whats your folder structure like?

My folder structure look like.

screen shot 2016-09-28 at 10 04 34 am

Code in service.container.js

const worker = new Worker('worker.js');
    //console.log(worker.postMessage)
    worker.postMessage("start");

Code in worker.js

import { self } from 'react-native-workers';
/* get message from application. String only ! */
self.onmessage = (message) => {
}

/* post message to application. String only ! */
self.postMessage("hello from worker");


even I am getting this error when using absolute path.

const worker = new Worker('http://www.w3schools.com/html/demo_workers.js');
    //console.log(worker.postMessage)
    worker.postMessage("start");

Could you please explain us how you fixed this issue. I am using React-Native 0.31 and having the same issue.

@StellwagJo Setting appropriate path should fix it. Let me know if u still have the problem.

Thanks the solution with appropriate path worked for me too.