Hi Per,
I see your point also :) In the following I'm not trying to convince
anyone - just thinking out loud..
On Fri, Nov 7, 2008 at 13:38, Per Cederberg <[EMAIL PROTECTED]> wrote:
> 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).
I have usually done this kind of thing with the stacking ability:
function makeAjaxCall(...) {
return getHTTP(...).addErrback(myGenericErrorHandler);
}
then use "makeAjaxCall" for all requests.
> 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.
I see. I think Deferreds can be easily extended to handle this case -
i.e. injecting functions in the chain that don't actually make use of
the result. Something like addCallbackPass(f) which would wrap f in a
function that passes the result and then addCallback that one.
> 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.
I see. It is a question of programming style - I think MochiKit
supports both nicely, we should maintain that in any additions to it.
cheers,
Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---