Permalink
Browse files

jQuery-style chaining of functions implemented.

  • Loading branch information...
1 parent 2c5945f commit 8b466beeec86fbc0c8393fb718533e32877906c0 @steveWang steveWang committed Jan 7, 2012
Showing with 13 additions and 1 deletion.
  1. +2 −1 lib/client/now.js
  2. +11 −0 lib/function.js
View
@@ -165,7 +165,7 @@
}
if(!(currVar[prop] && typeof currVar[prop] === "object")) {
currVar[prop] = {};
- }
+ }
currVar = currVar[prop];
}
return currVar;
@@ -368,6 +368,7 @@
}
}
socket.emit('rfc', {fqn: fqn, args: args});
+ return this;
};
remoteFn.remote = true;
return remoteFn;
View
@@ -5,6 +5,11 @@ exports.init = function (nowjs) {
multicall: function () {
var args = nowUtil.clone(Array.prototype, arguments);
nowjs.emit('multicall', this, args);
+ var o = this;
+ for (var x = this.fqn.split('.'), l = 0, ll = x.length - 1; l < ll; l++) {
+ o = o[x[l]];
+ }
+ return o;
},
remotecall: function () {
@@ -25,6 +30,11 @@ exports.init = function (nowjs) {
}
// On the next tick, send the remoteCall request
this.socket.emit('rfc', {fqn: this.fqn, args: args});
+ var o = this;
+ for (var x = this.fqn.split('.'), l = 0, ll = x.length - 1; l < ll; l++) {
+ o = o[x[l]];
+ }
+ return o;
},
closurecall: function (){
// Coerce arguments to an array.
@@ -46,6 +56,7 @@ exports.init = function (nowjs) {
}
}
this.socket.write(JSON.stringify({type:'closurecall', fqn: this.fqn, args: args}));
+ return this.now;
}
};
};

0 comments on commit 8b466be

Please sign in to comment.