Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.