Hello,
even if my last suggestion on how to "improve" the Deferred API has
been dismissed (with relevant arguments), I would like to ask for some
feedback on another code pattern I keep using over and over in my
code.
I am using Deferred a lot, and the only problem I am having with them
is how hard it is to understand what is going wrong while you are
developing; this is definitely not a problem caused by the Deferred
API, but I think the following suggestion could improve a little the
options available to "see" how the code behaves.
When I need to find out where a given deferred fails, I have get used
to fill my code with logging statement; the problem is that quite
often you are not interested in what happens when you build the
deferred, but you need to know what happens when the deferred is
fired. For this reason the statement I use is the following:
deferredResult.addBoth(function(res)
{MochiKit.Logging.logDebug("Comment " + res); return res;});
This statement is fired both for callbacks and errbacks, and takes
care to pass the current value to the next item in order to avoid
breaking the deferred parameter chain.
I think that a Deferred.logDebug method that simply perform the above
code would be quite helpful.
Another "problem" I am facing is relative to how exceptions are
managed by Deferred; the current implementation is perfectly fine, but
I feel it is missing a "top of stack" default handler.
I am used to catch exception only when I know what to do with them,
and not on every block. So when I concatenate many different deferred
chains, I often end up forgetting to add any errback handler. In this
way, even if an exception is raised somewhere down the chain, it pops
silently.
I think that having a default (configurable) errback (even a simply
alert would be useful sometimes) called if an exception is popping out
of the deferred chain without any handler to process it would be very
handy.
What do you think?
Giulio Cesare
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---