Skip to content

Instantly share code, notes, and snippets.

@justinrainbow
Forked from w33ble/gist:4121706
Created November 20, 2012 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinrainbow/4121808 to your computer and use it in GitHub Desktop.
Save justinrainbow/4121808 to your computer and use it in GitHub Desktop.
blah
function DataSourceQueue(config) {
// console.log(config, Y.DataSource.Local.transactions);
this._ds = config.host;
this.transactions = [];
this._ds.after('request', this.add, this);
this._ds.on('response', function(e) {
console.log('DS response', e.tId);
if (this.transactions[e.tId] === false) {
// this.halt();
// some magical method that escapes me goes here
} else {
this.remove(e.tId);
}
}, this);
}
DataSourceQueue.NS = 'dsq';
DataSourceQueue.NAME = 'datasourceQueue';
DataSourceQueue.prototype = {
add: function(e) {
var id = e.tId;
console.log('request '+id);
console.log(e);
this.clear();
this.transactions[id] = true;
},
remove: function(id) {
console.log('removing '+id);
var tx = Y.DataSource.Local.transactions[id];
console.log(tx);
if (tx && tx.abort) {
delete Y.DataSource.Local.transactions[id];
tx.abort();
}
this.transactions[id] = false;
},
clear: function() {
if (this.transactions.length > 0) {
for (i in this.transactions) {
this.remove(i);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment