jdonaldson / promhx

A promise and functional reactive programming library for Haxe
MIT License
146 stars 24 forks source link

Deferred.promise() return a new Promise each time #34

Closed wighawag closed 10 years ago

wighawag commented 10 years ago

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) ?

jdonaldson commented 10 years ago

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.

jdonaldson commented 10 years ago

Still working on this...

jdonaldson commented 10 years ago

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.