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

Is .Done() equal to JS .finally()? #22

Closed
PhilippCh opened this issue Sep 4, 2016 · 4 comments
Closed

Is .Done() equal to JS .finally()? #22

PhilippCh opened this issue Sep 4, 2016 · 4 comments

Comments

@PhilippCh
Copy link

PhilippCh commented Sep 4, 2016

I've read through the source and don't think .Done(resolved, rejected) is equal to JavaScript's .finally(), is that correct? I know that .finally() is not officially in the spec, but almost all non-native Promise implementations offer the functionality and I think it'd be quite useful for game-development purposes as well.

In that case, would you mind adding a .Finally(Action) method? I'll see if I can create a pull request myself if it's not already on your agenda.

Best Regards
Philipp

@zsoi
Copy link
Contributor

zsoi commented Sep 5, 2016

There is an open pull request for Finally() support: #20

@ashleydavis
Copy link
Contributor

Does anyone actually have a spec for how Finally should work?

@zsoi
Copy link
Contributor

zsoi commented Oct 24, 2016

The bluebird library has some good explanation about the behavior (http://bluebirdjs.com/docs/api/finally.html).

Some core points:

  1. Finally() should return a promise that is chained to the original promise
  2. Finally() can not modify the value of the original promise (i.e. it cannot return a new value) BUT
  3. Finally() can return a new promise, that is chained. When this chained promise fulfills, the value from that promise is discarded and the promise is fulfilled with the original promise value (see point 2). When the chained promise is rejected, than the original promise is rejected with that error. So Errors get propagated from Finally()-handlers, but values do not.

@RoryDungan
Copy link
Contributor

See issue #30 on how done works and #29 regarding finally support.

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

No branches or pull requests

4 participants