Closed ghost closed 12 years ago
Just have each function aside from the last one return this;
-- it should work.
For instance:
now.calc = {
val: 0,
add: function (i) {
this.val += i;
return this;
},
subtract: function (i) {
this.val -= i;
return this;
},
result: function () {
return this.val;
}
};
Actually, wait, you're probably referring to defining these functions server-side, yes? You'll probably want, first of all, to capture the result in a callback passed to now.calc.result()
. Also, I'm not entirely sure, will sift through code. I'll get back to you in a few.
edit: Nope, not supported. Awkward to implement fully.
Thanks for the help and I will take a look at the chaining branch. I understand this is not a desirable feature to implement.
It's not that it's undesirable; rather, it's just awkward and not quite the way the rest of NowJS works.
I am trying to chain functions then make them accessible for server access. Does now support this feature?
Chain example: now.calc.add(2).subtract(2).result();
Thanks