<HTML>
<HEAD>
<TITLE>Re: [Twisted-Python] Twisted vs jQuery Deferreds (was Re: RPC design questions)</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Found something: it seems in jQuery 1.6 they have introduced something which corresponds<BR>
more closely to Twisted Deferreds callback/errback chains:<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// prints 23<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sess.call(&quot;square&quot;, 23).pipe(function(res) {<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return sess.call(&quot;sqrt&quot;, res);<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}).pipe(console.log);<BR>
<BR>
<a href="http://api.jquery.com/deferred.pipe/">http://api.jquery.com/deferred.pipe/</a><BR>
<BR>
I am still wondering why they called the other stuff &quot;then()&quot; when it's not then, but &quot;also()&quot; <BR>
and &quot;pipe()&quot; is the real &lt;then&gt; ;)<BR>
<BR>
And now they have then() _and_ pipe().<BR>
<BR>
This is all asking for confusion. - Whatever.<BR>
<BR>
Tobias<BR>
<BR>
<BR>
On 25.08.11 00:52, &quot;Tobias Oberstein&quot; &lt;<a href="tobias.oberstein@tavendo.de">tobias.oberstein@tavendo.de</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Ok. This is most unpleasant. In particular since my options then are:<BR>
<BR>
1) write my own, sane (Twisted like, which I think is the sane way) JS deferred, not use jQuery/CommonJS (which everyone else does)<BR>
2) open the door for users running into issues when they do both Twisted &amp; JS/jQuery and don't understand the subtle difference<BR>
<BR>
bad.<BR>
<BR>
of course not a Twisted mailing list topic anymore .. I'll go to jQuery list.<BR>
<BR>
Thanks!<BR>
Tobias<BR>
<BR>
<BR>
On 25.08.11 00:36, &quot;Allen Short&quot; &lt;<a href="washort@twistedmatrix.com">washort@twistedmatrix.com</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>No, this is something jQuery and CommonJS got wrong; callbacks don't chain in their implementation. <BR>
<BR>
Firing a jQuery promise invokes each callback in order with the same argument. Firing a Deferred in Twisted invokes the first callback then passes its return value as the arg to the next callback, and so forth.<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>