有可能從直接代理類派生,以確保這樣的行爲:
/**
* A proxy class that ensures only the reponse to the last read request is
* processed.
*
* A quick user actions may result in more than one request sent to the server,
* but it is possible for the server to return a response to the second request
* before returning that of the first request. This will mean the the store
* will be populated with records that do not correspond to the latest user
* action.
*
*/
Ext.define('Ext.data.proxy.SerialDirect', {
extend: 'Ext.data.proxy.Direct',
alternateClassName: 'Ext.data.DirectSerialProxy',
alias: 'proxy.serialdirect',
doRequest: function(operation, callback, scope) {
this.callParent(arguments);
// Store the last read request
if (operation.request.action == "read") {
this.lastReadRequest = operation.request;
}
},
processResponse: function(success, operation, request, response, callback, scope) {
// abort if the request is a read one and does not correspond to the
// last read request
if (request.action == "read" && request != this.lastReadRequest)
return;
this.callParent(arguments);
}
});
感謝分享+1 – sra