Permalink
Browse files

Fixed callback signatures

  • Loading branch information...
1 parent 9de3c0f commit 346f4b7b3c504da3c370045f72fb932489fa5578 @tj tj committed Sep 7, 2010
Showing with 14 additions and 14 deletions.
  1. +1 −1 examples/google.js
  2. +5 −5 examples/google.nested.js
  3. +8 −8 lib/soda/client.js
View
2 examples/google.js
@@ -20,7 +20,7 @@ browser
.clickAndWait('btnG')
.assertTitle('Hello World - Google Search')
.testComplete()
- .done(function(err, res){
+ .done(function(err, body, res){
if (err) throw err;
console.log('done');
});
View
10 examples/google.nested.js
@@ -13,12 +13,12 @@ var browser = soda.createClient({
});
browser.session(function(err){
- browser.open('/', function(err, res){
- browser.type('q', 'Hello World', function(err, res){
- browser.clickAndWait('btnG', function(err, res){
- browser.assertTitle('Hello World - Google Search', function(err, res){
+ browser.open('/', function(err, body){
+ browser.type('q', 'Hello World', function(err, body){
+ browser.clickAndWait('btnG', function(err, body){
+ browser.assertTitle('Hello World - Google Search', function(err, body){
if (err) throw err;
- browser.testComplete(function(err, res){
+ browser.testComplete(function(err, body){
console.log('done');
});
});
View
16 lib/soda/client.js
@@ -47,13 +47,13 @@ Client.prototype.session = function(fn){
if (!this.browser) throw new Error('browser required');
if (!this.url) throw new Error('browser url required');
if (this.queue) {
- return this.enqueue('getNewBrowserSession', [this.browser, this.url], function(err, res){
- self.sid = res.body;
+ return this.enqueue('getNewBrowserSession', [this.browser, this.url], function(err, body){
+ self.sid = body;
});
} else {
- this.command('getNewBrowserSession', [this.browser, this.url], function(err, res){
+ this.command('getNewBrowserSession', [this.browser, this.url], function(err, body){
if (err) return fn(err);
- fn(null, self.sid = res.body);
+ fn(null, self.sid = body);
});
}
};
@@ -163,14 +163,14 @@ Client.prototype.done = function(fn){
Client.prototype.enqueue = function(cmd, args, fn){
var self = this;
this.queue.push(function(){
- self.command(cmd, args, function(err, res){
- fn && fn(err, res);
+ self.command(cmd, args, function(err, body, res){
+ fn && fn(err, body, res);
if (err) {
- self.done(err, res);
+ self.done(err, body, res);
} else if (self.queue.length) {
self.queue.shift()();
} else {
- self.done(null, res);
+ self.done(null, body, res);
}
});
});

0 comments on commit 346f4b7

Please sign in to comment.