On Fri, Nov 7, 2008 at 11:05 AM, Arnar Birgisson <[EMAIL PROTECTED]> wrote:
> As I understood the example, the objects being modified take care of
> calling signal(). E.g. a hash table that fires a signal when objects
> are added, removed and even when there's a collision. Guilio Cesare
> would like to be able to register for all signals. Perhaps a clearer
> API would be to allow wildcards in the second parameter to connect().

I see...

> This looks neat, and I have something similar implemented in many of
> my apps (generally I generate the code from the Python server side -
> i.e. any exposed ajax methods automatically get a corresponding JS
> function). However, I invariably opt for using deferreds instead of
> events.
>
> E.g. what happens in this case:
>
> dispatcher.getUser('john');
> dispatcher.getUser('paul');
> connect(dispatcher, "getUser", doSomething);
>
> Is doSomething called twice? Because maybe we want to do different
> things depending if it is the response for John or for Paul -- and we
> don't want to complicate doSomething with code to differentiate
> between them.

I see your point. I'm not trying to remove deferreds or anything. I
like them as much as you (I think). But in my apps I frequently write
code to handle variations of the following issues:

1. I want a generic error handler for most of my AJAX calls. Adding
one to each Deferred works for me, but others will probably forget it
(and I'm writing a webapp framework).

2. Showing and hiding spinning icons, enabling and disabling fields or
buttons is kind of messy to add to a deferred, since functions added
with addCallback and addErrback must return the input value to keep
Deferred processing intact. I'd like to do these UI changes more like
signals, connecting UI widgets to oncall and onresponse signals for
certain calls.

3. Keeping references to the currently running Deferreds, so that I
can cancel them easily on certain (but not all) UI events.

Basically, I want to achieve a more declarative style of programming.
Where I can setup signals and server-calls at startup, minimizing the
amount of code required in each individual UI event handler. Ideally I
just want the applications to be routing signals between DOM elements,
helper functions, server-side functions, other applications, etc.

Cheers,

/Per

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to