react-native-threads
react-native-threads copied to clipboard
Thread cannot run separately
@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.