briancavalier/when.js — Issue #6: Small improvement in public API
Author: gamtiq
Created: 2011-12-13 15:24:37+00:00
State: open

Hello,

First of all I would like to thank you for the great library.
I have an idea about small improvement in your library that could be helpful in some cases I suppose. The current implementation supports only functions as handlers/callbacks. This is quite restrictive for my application. Of course, I can use closures as wrappers for anything I need but… they are resource consuming tool and this is excess step in my case. So it would be useful to have a special public method (for example, when.execute) that is used to call/execute handlers (in _progress and notify functions) and can be redefined. By default this method may look like:

when.execute = function(handler, value, deferred) {
return handler(value);
};

The "deferred" parameter can be optional.

With best regards.