Results 1 to 2 of 2
  1. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #1  
    Okay, Ive searched google and this forum and only found this article on Palm's Developer page and this thread here regarding the issue I am having.

    I haven't been able to get the Mojo.Function.Synchronize, documented on Palms website, to work.

    The PreCentral thread I referenced above seems to be doing what I am attempting. Which is...

    ...in my MainAssistant.prototype.setup function, I make a DB query that populates a global array variable and a global rec_count variable. The DB query isn't finished before the next instruction is called in MainAssistant.prototype.setup which happens to use those global variables.

    The code looks something like this....
    Code:
    var sqlText = "SELECT * FROM datastore";
    
    this.db.transaction((function(transaction){ transaction.executeSql (sqlText, [], this.pullDbRecs.bind(this), this.errorHandler.bind(this));}).bind(this)); this.test();
    this.test, is just that,... a test function, that is trying to just print out the results of the DB query. The query is not given a chance to populate the global variables before this.test() is run and subsequently fails.

    Is there no way around this but to cycle through a loop until some global variable is populated or to use some obscure and difficult to implement function???

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  2. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #2  
    My attempt to get Mojo.Function.Synchronize to work looks something like this....

    I setup a new function MainAssistant.prototype.queryDB
    Code:
    MainAssistant.prototype.queryDB = function()
    {
         var sqlText = "SELECT * FROM datastore";
         this.db.transaction((function(transaction){
                  transaction.executeSql (sqlText, [],
                  this.pullDbRecs.bind(this),
                  this.errorHandler.bind(this));}).bind(this));
    }
    MainAssistant.prototype.setup looks like this now....
    Code:
    MainAssistant.prototype.setup = function()
    {
         var synchronizer = new Mojo.Function.Synchronize({
                              syncCallback: this.test(),
                              timeout: 10});
         var z = synchronizer.wrap(this.queryDB());
    }
    These yeilds the same results. A this.test() function that errors out cuz of unpopulated global variables.

    Palm Pre Backup Utility...done!
    Locate Pre....done!

Posting Permissions