You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Currently all my DB transactions are on main thread. I need to transfer them into worker thread.
Can you please tell me the best practices.
importScripts('SQLitePlugin.js');
self.addEventListener('message', function(ev) {
if (ev.data === 'go') {
sqlitePlugin.openDatabase({name:'my.db'}, function(db) {
db.executeSql("SELECT UPPER('Some US-ASCII text') as uppertext", [], function(res) {
self.postMessage('got uppertext: ' + res.rows.item(0).uppertext);
});
});
}
if (ev.data === 'welcome') {
sqlitePlugin.openDatabase({name:'my.db'}, function(db) {
db.executeSql("SELECT UPPER('Some US-ASCII text') as uppertext", [], function(res) {
self.postMessage('got uppertext: ' + res.rows.item(0).uppertext);
});
});
}
});
I dont want to openDatabase again and again for all the calls.
Is this possible that I open the DB in main thread and can pass the reference in the worker thread?
Please help!!
The text was updated successfully, but these errors were encountered:
Hi,
Currently all my DB transactions are on main thread. I need to transfer them into worker thread.
Can you please tell me the best practices.
importScripts('SQLitePlugin.js');
self.addEventListener('message', function(ev) {
if (ev.data === 'go') {
sqlitePlugin.openDatabase({name:'my.db'}, function(db) {
db.executeSql("SELECT UPPER('Some US-ASCII text') as uppertext", [], function(res) {
self.postMessage('got uppertext: ' + res.rows.item(0).uppertext);
});
});
}
if (ev.data === 'welcome') {
sqlitePlugin.openDatabase({name:'my.db'}, function(db) {
db.executeSql("SELECT UPPER('Some US-ASCII text') as uppertext", [], function(res) {
self.postMessage('got uppertext: ' + res.rows.item(0).uppertext);
});
});
}
});
I dont want to openDatabase again and again for all the calls.
Is this possible that I open the DB in main thread and can pass the reference in the worker thread?
Please help!!
The text was updated successfully, but these errors were encountered: