Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Deferreds without parameters #43

Open
brendanjerwin opened this issue Nov 18, 2014 · 4 comments
Open

Feature - Deferreds without parameters #43

brendanjerwin opened this issue Nov 18, 2014 · 4 comments

Comments

@brendanjerwin
Copy link

There are a few cases where it'd be nice to have a Deferred that had no payload type. In that case, .Then would take Void->Void.

The fact that it resolved or failed is all the information that is needed in some cases.

(failing would still carry the error though.)

@jdonaldson
Copy link
Owner

Sorry for the delay. I'm keeping this in the back of my mind, but I don't have a pressing need for the proper feature since a workaround is so easy.

@brendanjerwin
Copy link
Author

While it is true that the workaround is easy, it does clutter up my APIs with misleading information.
"What am I supposed to do with this boolean?" my clients are asking. :)

@jdonaldson
Copy link
Owner

I'll keep this open, but for what it's worth this seems pretty unlikely that I'll get it working properly.

Firstly, some haxe targets have a problem with a Promise type, as seen in #20.
Secondly, even if I got it working well, it's not really a great fit for what this library is about. In the intro, I specifically mention that promises and streams are all about asynchronous values. I.e., if there's no value to be delivered, then the notion of a promise/stream seems strange.

If this issue was about functionality, I'd think harder about a workaround. But, since it's about elegance, ease, and clarity, I'm seeing arguments both ways.

@hexonaut
Copy link

TBH I use void promises all the time. Very useful if you are only interested in the success or failure of an operation. My quick solution was to just define a dumy type to represent a void promise:

typedef VoidPromise = Promise<Dynamic>;

That way users of the promise will understand the return value is garbage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants