Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha Premium Member natedsaint's Avatar
    Join Date
    Jul 2012
    Location
    Fort Worth, TX
    Posts
    21
    Vote Rating
    3
    natedsaint is on a distinguished road

      0  

    Default Callback on store's sync() method does not occur after the batch is complete

    Callback on store's sync() method does not occur after the batch is complete


    I'm not entirely sure what event actually results in the callback, but the store's sync method appears to fire the callback before the sync is complete. In our example, a batch operation of multiple creates fires the callback before all records have been created and returned from the database. So:

    Code:
      myStore.sync({
        callback: function() { 
          MyApp.App.fireEvent('mystore.completed');
        }
      });
    Causes the event "mystore.completed" to be fired BEFORE the set of records are done. I was able to get around this by adding this to the proxy of the model used:

    Code:
    proxy: {
      onBatchComplete: function() {
        MyApp.App.fireEvent('mystore.completed');
      }
    }
    Then, I just call mystore.sync();

    To me, this is a problem with the functionality of sync()'s callback.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Can I get a test case?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    1
    Vote Rating
    0
    gbtekkie is on a distinguished road

      0  

    Default


    I am for example trying to do the following, and the sync() method is not called either.

    Code:
            // grab settings
            var store = Ext.getStore('SettingsStore');
            var storeLocal = Ext.getStore('SettingsStoreLocalStorage');
    
    
            store.load({
                callback : function(records, operations, success) {
                    storeLocal.add(store.first());
                }
            });
    
    
            storeLocal.sync({
                callback : function() {
                    console.log('syncing local storage');
                }
            });

  4. #4
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    7
    Vote Rating
    0
    mpuccerella is on a distinguished road

      0  

    Default


    Quote Originally Posted by gbtekkie View Post
    I am for example trying to do the following, and the sync() method is not called either.

    Code:
            // grab settings
            var store = Ext.getStore('SettingsStore');
            var storeLocal = Ext.getStore('SettingsStoreLocalStorage');
    
    
            store.load({
                callback : function(records, operations, success) {
                    storeLocal.add(store.first());
                }
            });
    
    
            storeLocal.sync({
                callback : function() {
                    console.log('syncing local storage');
                }
            });

    Calling sync in this manner will not work. There are no staged changes at the point you call sync. This causes sync to immediately return and not fire your callback.