Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use third party packages in the working.thread.js? #82

Open
neller1 opened this issue Oct 1, 2019 · 3 comments
Open

How can I use third party packages in the working.thread.js? #82

neller1 opened this issue Oct 1, 2019 · 3 comments

Comments

@neller1
Copy link

neller1 commented Oct 1, 2019

When I import package to working.thread.js code to use it, I get the error "null is not an object (evaluating 'Package_Name')"
So, how can I use packages in the threads?

import { self } from 'react-native-threads';
import './config';
import { start, stop } from "react-native-beep-tone";
  var g=false;
	self.onmessage = message => {
		for (let i = 1; i <= 30; i++){
		  setTimeout(function(){
			//console.tron.log(`THREAD: got message ${i}`);
				g=!g;
				if (g){
					start(50);     // Start playing the sound
					
				}
				else{
					stop();            // Stop playing the sound
					
				}
			
			//self.postMessage(`Message from worker thread!`);
		  }, i * 1000);
		}
	}
	

@minicuper
Copy link

Probably this way - https://github.com/joltup/react-native-threads#android-1

Also note that only the official react native modules are available from your threads (vibration, fetch, etc...). To include additional native modules in your threads, pass them into the RNThreadPackage constructor after the mReactNativeHost like this: new RNThreadPackage(mReactNativeHost, new ExampleNativePackage(), new SQLitePackage())

@daominhsangvn
Copy link

How can i archive this in ios ?

@RiteshJariwala
Copy link

what about if some want to import all the package.json modules to it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants