I'd like to be able to show a message to the user once a store sync has successful completion. However, there doesn't seem to be any way of using a callback or calling this synchronously. I'm a little surprised this isn't provided out of the box as it must be a common problem.
Is there any work-around for this?
It took us ages to find a proper solution to this. Finally we added listener to the store's write event what seems to be working properly. As it is needed frequently it has been added to the store prototype as
Ext.data.Store.prototype.syncWithListener = function(onWriteComplete, syncMethod) {
this.on('write', onWriteComplete, this, {single:true});
var syncResult = syncMethod ? syncMethod.apply(this) : this.sync();
if (syncResult.added.length === 0 &&
syncResult.updated.length === 0 &&
syncResult.removed.length === 0) {
this.removeListener('write', onWriteComplete, this, {single:true});
onWriteComplete(this);
}
return syncResult;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With