So I have a Javascript Class that wraps and manages access to the WebSQL Database system.
the code for the class can be found: https://jsfiddle.net/dsct89kv/
now to test it I'm using
function(){
var test = new Database();
test.open("test");
test.query("CREATE TABLE `logs` (id INTEGER PRIMARY KEY, value VARCHAR)");
test.query("SELECT * FROM `logs`");
test.waitForBlockLift();
console.log(test.fetchRows());
}
if I run all of these line by line one after another in the console it works perfectly but if I run the group it becomes thread locked on test.waitForBlockLift();
so that is defined as
this.isBlocked = function(){ return blocking; };
this.waitForBlockLift = function(){
var test = this.isBlocked();
while(test){
test = this.isBlocked();
}
return true;
}
the initial value of blocking
= false when a query is called test.query
it is set to true and once the transaction has completed and called the callback then set it back to false but for some reason when I call in a single line from the Console e.g test.query("SELECT * FROM logs"); test.waitForBlockLift(); console.log(test.fetchRows());
that does not happen the javascript engine works as I can still use the console. however, I can't access test and the tread appears to lock the whole point was to enable it to wait for the thread to unlock.
I must be doing something wrong but can't work out what