Would the function that is registered/executed by the then
method be able to catch hold of its own resolve?
A promise when its constructed is able to inject its resolve method like:
new Promise(function(resolve, reject){ async(resolve();})
However the action registered by then normally is triggered in resolve method like (at least in some examples I have seen):
resolve = function(value){
self.value = value;
self.state = "resolved";
deferred.resolve(deferred.transform(self.value));
}
There is no real means to inject deferred.resolve
into deferred.transform
method. It almost as if the then
doesn't expect the function it would execute to be asynchronous unlike like a Promise Constructor and hence it isn't isomorphic?
In Javascript Promise Sequence you actually create 8 Promises for a job that should ideally be done in 4 Promises. Can't this be solved if the transformation function registered by then
can get hold of its own resolve
which is the deferred.resolve
? The transformation function can be ansychronous and it can resolve
it when it's done.