Skip to content

Instantly share code, notes, and snippets.

@w33ble
Created November 20, 2012 22:32
Show Gist options
  • Save w33ble/4121706 to your computer and use it in GitHub Desktop.
Save w33ble/4121706 to your computer and use it in GitHub Desktop.
blah
function DatastoreQueuePlugin(config) {
// console.log(config, Y.DataSource.Local.transactions);
this._ds = config.host;
console.log(this._ds, this._ds._queue);
this.transactions = [];
this._ds.on('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);
}
DatastoreQueuePlugin.NS = 'DatastoreQueue';
DatastoreQueuePlugin.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);
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