joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
756 stars 142 forks source link

Thread cannot run separately #92

Open nagaraj95 opened 5 years ago

nagaraj95 commented 5 years ago

@Traviskn i am using initially to get the data from local db and sets the data to UI. After tat I invoke a function to sync data to local db with the server, while syncing with server i cannot able to perform a operation like on-press. So i used this library to run that function in separate thread to avoid that UI block operation, but at ta time also the UI blocks after the execution of the function i can able to perform the operation on-press.I used the syntax like tis

 const thread = new Thread('app/thread.js')         
        thread.postMessage('hello');
         thread.onmessage = (message) => {
             console.log("-------" + message);
             this.syncDbWithServer()
         }

Thread.js file

import { self } from 'react-native-threads'; self.onmessage = async (message) => { console.log("msg----", message) self.postMessage('11111111111'); } Is there any solution for tis. Thanks in advance.