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

Use a promise library #7

Open
monteslu opened this issue Feb 1, 2017 · 2 comments
Open

Use a promise library #7

monteslu opened this issue Feb 1, 2017 · 2 comments

Comments

@monteslu
Copy link

monteslu commented Feb 1, 2017

Results with a .then are generally thought to be promises. The issue here is that the result isn't a real promise and doesn't conform the promises A+ spec.

This becomes a problem for example if you want to handle an exception you might assume that you can attach a .catch() to the result.

@platypii
Copy link
Contributor

platypii commented Feb 1, 2017

When this was written, we tried to conform to the promises/A+ spec available here: https://promisesaplus.com/

There is nothing about .catch() in that spec, just onFullfilled and onRejected callback arguments to .then().

I do see that mozilla defines .catch() in their native Promise type. Will look into what it would take to implement this. Pull requests are also gratefully accepted :-)

@anowell
Copy link
Contributor

anowell commented Feb 1, 2017

I think it's the browser JS client that conforms a bit better to promises/A+.

I also don't see anything regarding .catch() in the spec, but I can at least enumerate a few places where this client is out-of-spec:

  • there is no onRejected - instead we always fulfill with a value that could contain a result or an error. This presumably makes it harder to compose effectively with other promise-wrapping libraries (async comes to mind)
  • we don't allow multiple callbacks, let alone a chainable interface or order guarantees

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

3 participants