-
-
Save justinrainbow/4121808 to your computer and use it in GitHub Desktop.
blah
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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