react-native-workers icon indicating copy to clipboard operation
react-native-workers copied to clipboard

Error downloading web worker

Open jitenderchand1 opened this issue 10 years ago • 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 avatar Sep 27 '16 11:09 jitenderchand1

@jitenderchand1 Whats your folder structure like?

RichardBoyewa avatar Sep 27 '16 19:09 RichardBoyewa

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");

jitenderchand1 avatar Sep 28 '16 05:09 jitenderchand1

fixed

jitenderchand1 avatar Sep 28 '16 07:09 jitenderchand1

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

StellwagJo avatar Sep 29 '16 13:09 StellwagJo

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

RichardBoyewa avatar Oct 01 '16 04:10 RichardBoyewa

Thanks the solution with appropriate path worked for me too.

StellwagJo avatar Oct 05 '16 09:10 StellwagJo