joltup/react-native-threads

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

neller1 opened this issue · 3 comments

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

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())

How can i archive this in ios ?

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