react-native-workers
react-native-workers copied to clipboard
Debug index.worker.js
big thanks, this is a nice componen... its really help me to create a background service...
every time i want to test my index.worker.js using this script : node node_modules/react-native/local-cli/cli.js start --reset-cache node node_modules/react-native/local-cli/cli.js start --port 8082 --reset-cache concurrently --kill-others "npm run start-app" "npm run start-worker" adb reverse tcp:8081 tcp:8081 && adb reverse tcp:8082 tcp:8082 node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.android.js --platform android --bundle-output ./android/app/src/main/assets/index.android.bundle --sourcemap-output ./sourcemap/android.main.map node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.worker.js --platform android --bundle-output ./android/app/src/main/assets/index.worker.bundle --sourcemap-output ./sourcemap/android.worker.map npm run bundle-app-android && npm run bundle-worker-android concurrently --kill-others "npm run bundle-ios" "run bundle-android\
but i can not debug...
can u give me the tutorial to debug my index.worker.js file?
thanks in advanced
Sorry for my absence, my work and freelances was making me crazy. I'll start working in this project again this week.
Runnning on Android you should be able to debug by enabling the debug mode with a shake as usual. Will show up 2 dialogs, one is for the main bundle and another for the worker, I don't remember the order.
On iOS since all modules are "singletons", if you enable debug mode for one, it will enable for the worker.
hi... thanks for the reply
is it true if i want to change my code on worker then i must re-run this script: node node_modules/react-native/local-cli/cli.js start --reset-cache node node_modules/react-native/local-cli/cli.js start --port 8082 --reset-cache concurrently --kill-others "npm run start-app" "npm run start-worker" adb reverse tcp:8081 tcp:8081 && adb reverse tcp:8082 tcp:8082 node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.android.js --platform android --bundle-output ./android/app/src/main/assets/index.android.bundle --sourcemap-output ./sourcemap/android.main.map node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.worker.js --platform android --bundle-output ./android/app/src/main/assets/index.worker.bundle --sourcemap-output ./sourcemap/android.worker.map npm run bundle-app-android && npm run bundle-worker-android concurrently --kill-others "npm run bundle-ios" "run bundle-android\
if it is in debug mode, you should be able to reload the code using "Reload" in the shake menu. But the library is still a little unstable since running another "Application" in a environment where there is a lot of share instances between main bundle and worker bundle.
wow...great info for me...
my application have realm database... how can i query to realm database from my index.worker.js
when i put this code "import realm from 'realm'" then red screen show up with this comment: "missing realm constructor - please ensure RealmReact framework is included"
my goal with this worker is check to my realm database if flag_uploadstatus 0 then i upload to my api using axios...
I don't like to give bad news, but... I already tried to use realm using workers and was veeeeeeeeery unstable, on iOS I could not even generate a release version.
On Android you need to add the RealmPackage using RNWorker.Builder and you should not load the realm package in your main bundle.
final RNWorker worker = new RNWorker.Builder(this, false)
.entryPoint(RNWorker.DEFAULT_JS_ENTRY_POINT)
.bundleAsset(RNWorker.DEFAULT_JS_BUNDLE_ASSET)
.port(8088) //Realm already use 8082 to load a nano server to connect to chrome debug
.packages(
new RealmReactPackage()
).build();
so the conclusion i can query from worker "ON ANDROID", but its unstable... so sad to here it...
finally thanks for the information... great component... i believe i would be better... i will waiting for the stable one.... good job bro
you have any advice to run background service like case that i faced?
No, sorry :(
In my project I was even considering using native realm instead of realm-js because of the chrome debug performance.
@fabriciovergal, is this caused by the realmjs requirement for the tx to be sourced from the main thread?
Actually I could not find exactly why its not work. Running on development environment I managed to make it work (after a long time trying), but when I tried to generate a release, the application was crashing on start with meaningless logs.
On iOS was even more problematic, because I could not found a way to keep the main bundle with debug mode on and the worker with debug mode off, because this settings is managed by a singleton object. And with it, come the chrome debug performance issue.
Yes, that chrome debugging perf makes it almost unusable.
Great library! But really sad to know that it's not working with realm....
Hi Fabricio, im still working with realm on native android... but i cannot make it work...
would u share how i can query my react native DB with native realm on android and ios.. thanks
@apuyapuy, before I switched earlier this year, realmdb didn't support cross-thread access in realmjs.