Results 1 to 4 of 4
  1.    #1  
    I am having an issue loading info from a depot saved file. My app opens a depot and sets a list = to the list stored in the depot. Then a scene is pushed which will display the information in the newly loaded list. Problem is, when the card opens up, the list widget is blank as if there were no items in the list. I made a special refresh key, which when pressed does nothing but call “this.controller.modelChanged(this.beerModel);” and the list shows up just fine. I put logging info into the code and found that the order in which everything was executed is off…

    App opens and I get a message that the “DB opened OK”, next line says “scene opened OK”, followed by “finished loading list”.

    If you follow the code line by line, “finished loading list” should appear before “scene opened OK”.

    If I force the app to think the DB didn’t open OK, it loads a default hard coded list just fine and when the scene is first pulled up it has the full list without having to do a manual refresh.

    My question is this: is there a way to have my app wait for the DB to finish loading so that I can then pull up the scene with he full list displayed? Apparently the DB opens up but then the code continues to run while the info is being loaded which explains why the list has to be refreshed. I have searched but see no methods which would return that the DB has finished loding data.

    I posted this basic question before, but no one replied with an answer.
  2. #2  
    Quote Originally Posted by sinime View Post
    [snip] My question is this: is there a way to have my app wait for the DB to finish loading so that I can then pull up the scene with he full list displayed? Apparently the DB opens up but then the code continues to run while the info is being loaded which explains why the list has to be refreshed. I have searched but see no methods which would return that the DB has finished loding data.

    I posted this basic question before, but no one replied with an answer.
    The depot should look something like:
    Code:
    this.db = new Mojo.Depot(
    			{
    				name: "nameofDB",
    				version: 1,
    				estimatedSize: 100000,
    				replace: false
    			},
    			this.openGood.bind(this),
    			function(result) {
    				console.log("Can't open database: ", result);
    			}
    		);
    
    	openGood: function() {
    		this.db.simpleGet("nameofData", this.loadDbGetSuccess.bind(this), this.loadDbUseDefault.bind(this));
    	},
    So the code that depends on the data from depot, should be in loadDbGetSuccess so that it executes AFTER the depot database is read.

    Does that help?
    mobigamedepot.com
  3.    #3  
    Quote Originally Posted by djpushplay View Post
    The depot should look something like:
    Code:
    this.db = new Mojo.Depot(
    			{
    				name: "nameofDB",
    				version: 1,
    				estimatedSize: 100000,
    				replace: false
    			},
    			this.openGood.bind(this),
    			function(result) {
    				console.log("Can't open database: ", result);
    			}
    		);
    
    	openGood: function() {
    		this.db.simpleGet("nameofData", this.loadDbGetSuccess.bind(this), this.loadDbUseDefault.bind(this));
    	},
    So the code that depends on the data from depot, should be in loadDbGetSuccess so that it executes AFTER the depot database is read.

    Does that help?
    I can try pulling the card/scene up within the load success, but as it is right now, the scene shouldn't be pulled till after the Depot is loaded...

    In my stage-assistant I have:
    Code:
     this.masterBeerList = new Beers();
    this.masterBeerList.loadBeerDb();
    this.controller.pushScene("beerListView", this.masterBeerList, this.acctList, this.storeList);
  4. #4  
    Quote Originally Posted by sinime View Post
    I can try pulling the card/scene up within the load success, but as it is right now, the scene shouldn't be pulled till after the Depot is loaded...

    In my stage-assistant I have:
    Code:
     this.masterBeerList = new Beers();
    this.masterBeerList.loadBeerDb();
    this.controller.pushScene("beerListView", this.masterBeerList, this.acctList, this.storeList);
    This is exactly the problem you're having. Javascript will not "wait" for loadBeerDb to finish before executing the next line. That's why they have the function to call when completed. Just move things around a bit and it should work. However, be sure you don't have a recursion stack problem. As long as it only happens once, it should be okay. In other words, make sure your "beerListView" code doesn't also have the same code inside that would cause recursion.

    Regarding this JSJSJS &$quot$;$problem$&$quot$;, $I$'$ve$ $had$ $the$ $exact$ $same$ $problem$ $when$ $loading$ $image$ $files$ $where$ $I$ $try$ $using$ $the$ $width$/$height$ $of$ $the$ $image$ $immediately$ $after$ $but$ $the$ $data$ $is$ $not$ $available$. $I$ $had$ $to$ $put$ $it$ $inside$ $the$ &$quot$;$onload$&$quot$; $function$ $to$ $make$ $sure$ $that$ $the$ $data$ $had$ $been$ $loaded$.

    Good luck. Post again if you still have questions.
    mobigamedepot.com

Posting Permissions