jdonaldson/promhx

Deferred.promise() return a new Promise each time

wighawag opened this issue · 3 comments

Hi,

Just started using the new version which split promhx api into "Deferred and Promise".
While I like the fact that you can choose to not expose the resolve function for the one who do not need it, I am not sure why Deferred.promise() return a different promise on each invocation.

This pose problem for me where I need to store both Promise and Deferred in order to be able to both potentially reject (which is only available on Promise) AND resolve (only available on deferred) at a later time.

Could Deferred return only one promise/ or keep track of its created promise (so I can rejectAll) ?

Yeah, I think we need to go with a 1:1 mapping for deferreds and streams/promises. I'll put together a patch. This might break some code, but hopefully it will be very minimal.

Still working on this...

I added a new "deferred" module that contain some deferred definitions that come pre-bound to a given Stream/Promise instance. It should make it easier to pass one instance around for both.