Accessing Non-RN-core Native packages in a worker thread.
See original GitHub issueHello, Thanks for the fabulous work done on this topic.
Is there any way we can integrate an additional non-RN-core native package into a worker?
We are trying to create a worker that reads the phone-book (a processing-heavy op) and store results for quicker retrieval later.
Outline of my code:
index.worker.js:
import { WorkerService } from 'rn-workers'
import ContactsBackground from './ContactsBackground';
const worker = new WorkerService();
worker.onmessage = (message) => {
//Start the worker and pray!
console.log('Inside worker - outermost');
ContactsBackground.start();
}
Main worker - ContactsBackground.js:
module.exports = {
start: function(){
var Contacts = require('react-native-contacts'); //External module of interest
Contacts.getAll((err, contacts) => {
// Do something
});
}
}
The system setup is pretty smooth but the worker halts at Contacts.getAll(…) with a message that Contact.getAll is undefined. (Link to module readme: https://github.com/rt2zz/react-native-contacts )
Any help is very much appreciated.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Require for native add-ons in worker_threads #34 - GitHub
Starting from Node.js 11.11.0 (nodejs/node#26175) it should be possible to use native addons from multiple worker threads as long as they ...
Read more >Is there a way to run native code modules using worker threads?
Is it possible to use native code modules on worker threads? I am creating each worker thread as shown: const { Worker } ......
Read more >Worker threads | Node.js v19.3.0 Documentation
The node:worker_threads module enables the use of threads that execute JavaScript in parallel. To access it: const worker = require('node:worker_threads');.
Read more >Using worker_threads in Node.js - Medium
This is a beginner's guide to using worker_threads in Node.js. ... It is true if we are in the main thread (that is,...
Read more >Using instrumented clients in worker threads - AWS X-Ray
Scorekeep uses a worker thread to publish a notification to Amazon SNS when a ... NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In iOS all RN Packages are “singletons”, so when you create a worker, all custom packages will be automatically linked to this worker.
How do we do this in iOS