[Twisted-Python] Twisted vs jQuery Deferreds (was Re: RPC design questions)

Jasper St. Pierre jstpierre at mecheye.net
Wed Aug 24 19:36:39 EDT 2011


As far as I know, Dojo's Deferreds are a direct port of Twisted's.

On Wed, Aug 24, 2011 at 7:30 PM, Tobias Oberstein
<tobias.oberstein at tavendo.de> wrote:
> Found something: it seems in jQuery 1.6 they have introduced something which
> corresponds
> more closely to Twisted Deferreds callback/errback chains:
>
>             // prints 23
>            sess.call("square", 23).pipe(function(res) {
>                                             return sess.call("sqrt", res);
>                                         }).pipe(console.log);
>
> http://api.jquery.com/deferred.pipe/
>
> I am still wondering why they called the other stuff "then()" when it's not
> then, but "also()"
> and "pipe()" is the real <then> ;)
>
> And now they have then() _and_ pipe().
>
> This is all asking for confusion. - Whatever.
>
> Tobias
>
>
> On 25.08.11 00:52, "Tobias Oberstein" <tobias.oberstein at tavendo.de> wrote:
>
> Ok. This is most unpleasant. In particular since my options then are:
>
> 1) write my own, sane (Twisted like, which I think is the sane way) JS
> deferred, not use jQuery/CommonJS (which everyone else does)
> 2) open the door for users running into issues when they do both Twisted &
> JS/jQuery and don't understand the subtle difference
>
> bad.
>
> of course not a Twisted mailing list topic anymore .. I'll go to jQuery
> list.
>
> Thanks!
> Tobias
>
>
> On 25.08.11 00:36, "Allen Short" <washort at twistedmatrix.com> wrote:
>
> No, this is something jQuery and CommonJS got wrong; callbacks don't chain
> in their implementation.
>
> 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.
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>



-- 
  Jasper



More information about the Twisted-Python mailing list