Skip to content

Commit

Permalink
Extending IO so that { xdr: { use: 'nodejs' } } is no longer required.
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Nov 1, 2010
1 parent 6085b39 commit 3a957f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 0 additions & 9 deletions examples/io.js
Expand Up @@ -18,9 +18,6 @@ YUI({
var url3 = 'http:/'+'/localhost:8500/';

Y.io(url, {
xdr: {
use: 'nodejs'
},
on: {
start: function() {
Y.log('Start IO', 'info', 'TEST');
Expand All @@ -34,9 +31,6 @@ YUI({


Y.io(url2, {
xdr: {
use: 'nodejs'
},
method: 'POST',
headers: {
foo: 'bar'
Expand All @@ -55,9 +49,6 @@ YUI({


Y.io(url3, {
xdr: {
use: 'nodejs'
},
on: {
start: function() {
Y.log('Start IO', 'info', 'TEST');
Expand Down
18 changes: 18 additions & 0 deletions lib/io.js
Expand Up @@ -119,7 +119,25 @@ YUI.add('io-nodejs', function(Y) {
}
};

/**
* HACK - I don't like this, but this is the only way I can intercept io calls
* and auto apply the xdr config option.
*/
var _io = Y.io;
Y.io = function(url, config) {
if (!config) {
config = {};
}
config.xdr = { use: 'nodejs' };
return _io(url, config);
}
for (var i in _io) {
Y.io[i] = _io[i];
}

Y.io.transport(NodeTransport);



}, 'NODE', { requires: ['io', 'io-xdr'], after: ['io-xdr'] });

0 comments on commit 3a957f4

Please sign in to comment.