I work as part of a telephone circuit. I use two stream functions. The first thread calls the API method to receive a message from the web server to insert the sqlite database, and the other thread calls the list data from Sqlite in the user interface, which means my inbox. the problem is that the device hangs on the continuation of the stream in the queue. so i want to use android and ios background thread plugin. Does anyone know about a phone saver background thread plugin. Please help me.
This is the first stream function.
function itmerStart()
{
if (timerId) return
var busy = false;
timerId = setInterval(loadMessageListCron, 20000);
function loadMessageListCron()
{
$.ajax("http://mysamplesite.com/API/getallmessages?UserId="+ userid).done(function(data)
{
var i, response;
$.each(data.messages, function (i, response)
{
inboxMessageItmerStop();
insertMessages(response, i);
inboxMessageItmerStart();
});
});
}
}
this is the second function of the stream.
function inboxMessageItmerStart()
{
if (timersId) return
timersId = setInterval(loadInboxMessageList, 5000);
var busy = false;
function loadInboxMessageList()
{
if(!busy)
{
busy = true;
var userid = window.localStorage.getItem("userId");
if(userid != undefined)
{
db.transaction(queryDB,errorCB);
}
busy = false;
}
}
}
source
share