Workaround for Ext JS store-sync-callback not called when no modifications took place

Somewhere back in time the `Ext.data.Store`-sync method got a callback-option which is called when the sync-operation completes. But this callback is not executed if there are no modifications to the store (no add, no delete, no update). Which seems a bit odd imho.

If the codes relies on the callback beeing always executed whent the sync is complete you are in trouble. The workaround is to check the store for modifications like so. Not really elegant but does the job…

var isModified = tehStore.getNewRecords().length > 0 || 
  tehStore.getUpdatedRecords().length > 0 || 
  tehStore.getRemovedRecords().length > 0;
 
if(!isModified) {
  tehCallback();
} else {
  tehStore.sync({
    callback: tehCallback
  });
}