Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    15
    Vote Rating
    0
    Simon Tomlin is on a distinguished road

      0  

    Default Answered: Confused about how or when a store is loaded

    Answered: Confused about how or when a store is loaded


    I am using the draw component and need to render a bunch of sprites onto the surface.

    The information for all this is to be loaded into a store which will contain models which in turn contain the information needed to determine what is needed to be created.

    My problem is knowing when the store has been loaded so as then to create the sprites which are then added to the surface.

    This has been testing me for about three days which probably means its starring me in the face but I would be very grateful if someone could point out what I am missing from the code below

    Code:
    onLaunch: function() {
    this.getBattlefieldStore().load();
    console.log('Contoller on launch function ' + this.getBattlefieldStore().count());
    var myStore = this.getBattlefieldStore();
    myStore.load({
        scope   : this,
        callback: function(records, operation, success) {
            //the operation object contains all of the details of the load operation
            console.log('One more time as deparate ' + myStore.count());
            console.log('One more time as deparate2 ' + this.getBattlefieldStore().count());
        }
    });
    
    
    console.log('Checking the battlefield store has ' + myStore.count());
    }
    });
    This is the firebug console output

    Contoller on launch function 0
    Checking the battlefield store has 0
    One more time as deparate 1
    One more time as deparate2 1


    As can be seen the store is not loaded on the first and last check but inside the load it is called on both the var myStore and the this.getBattlefieldStore() reference which is automatically created for the class.
    There is only one record to load.

    So I am confused when does my store actually get loaded and when can I access the models?

    This is the controller definition

    Code:
    Ext.define('BTT.controller.BattleMap', {
        extend: 'Ext.app.Controller',
        models: ['Unit'],
        stores: ['Battlefield'],
        views: ['BattleMap'],
    Desperately hoping its something obvious

    Thanks in advance
    Simon


  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,475
    Answers
    523
    Vote Rating
    280
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    The call to load() is asynchronous, i.e. non-blocking. This means that it initiates the loading process but returns before it has actually loaded. Code that follows the load call will always run before loading is complete. This is necessary when loading data from a server as performing the load synchronously would cause the entire app to stop responding until the request is complete.

    The callback will only be invoked once the store has actually loaded the data.

    This is a relatively common paradigm in JavaScript. It stems from the use of AJAX. As you may be aware, the first A in AJAX stands for asynchronous.

    Is this what you were asking or have I just answered a totally different question?

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    15
    Vote Rating
    0
    Simon Tomlin is on a distinguished road

      0  

    Default


    Quote Originally Posted by skirtle View Post
    The call to load() is asynchronous, i.e. non-blocking. This means that it initiates the loading process but returns before it has actually loaded. Code that follows the load call will always run before loading is complete. This is necessary when loading data from a server as performing the load synchronously would cause the entire app to stop responding until the request is complete.

    The callback will only be invoked once the store has actually loaded the data.

    This is a relatively common paradigm in JavaScript. It stems from the use of AJAX. As you may be aware, the first A in AJAX stands for asynchronous.

    Is this what you were asking or have I just answered a totally different question?
    Thank you for your reply

    I think you have answered what is actually happening and I guess that is the problem.

    I have basically a simple MVC app which calls the viewport which has a border layout of two. The north is just a panel while the centre is a draw component.

    There is one controller which is attached to the draw component which needs to add sprites to the surface based on what is in the store. The issue seems to be that I cannot work out when I get a notice that the store has been loaded.

    I believe it goes like this :- app - instances controller - controller instances store which is set up for autoload and fetches the data. The problem is I have not yet figured out where I am supposed to code the sprite creation to add to the surface which can only happen once the store is loaded.

    So really the question is where do I catch the event which says the store is ready when using the MVC architecture and the store is created by the controller? I really want it in the controller but have failed to find it.

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Location
    Sweden
    Posts
    36
    Answers
    10
    Vote Rating
    0
    JambaFun is on a distinguished road

      0  

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    15
    Vote Rating
    0
    Simon Tomlin is on a distinguished road

      0  

    Default


    Quote Originally Posted by JambaFun View Post
    Yea Thanks, I missed the load event on the store and was assuming that the controller onLaunch function would not fire until the store load had been completed but it does. This caused no end of problems looking at the get call to the php code on the server assuming there was the problem.

    It was only when I used the callback I was certain the data was actually being read. It was a bit of a give away that the console output was the last but the calls were not.

    Anyway, I'll place the code in the load event to call the controller to notify it then its ok to use the data.

    Thanks for the reply and also thanks to stirle for pointing me in the right direction.
    Last edited by Simon Tomlin; 26 Oct 2011 at 6:33 AM. Reason: spelling

  6. #6
    Sencha User
    Join Date
    Oct 2011
    Posts
    15
    Vote Rating
    0
    Simon Tomlin is on a distinguished road

      0  

    Default What worked

    What worked


    Just as a last post in case anyone else lost the plot while working through the MVC example

    In order to use the store after it had loaded I needed to add a listener to the store which is automatically created by the controller in the controller init like so

    Code:
    this.getBattlefieldStore().on('load',this.onStoreLoad,this);
    Then code the function onStoreLoad() in the controller which is called after the store is loaded.

    Of course, it all seems so obvious now.

    Thanks to the posts for the help

    Simon

Thread Participants: 2