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

Remove callback parameter #109

Open
JMPerez opened this issue Aug 23, 2018 · 2 comments
Open

Remove callback parameter #109

JMPerez opened this issue Aug 23, 2018 · 2 comments
Labels

Comments

@JMPerez
Copy link
Owner

JMPerez commented Aug 23, 2018

The functions in the library support two ways of getting the result of the request back. One of them is through a promise that is returned in the call, and the other one is a callback parameter that gets called with the data and eventual error.

The support for Promise is quite widespread at the moment and additions to the language like async/await, which allows a concise syntax around Promises, make this option the preferred one.

The idea is to get through some of the packages and projects that depend on the library and analyze how frequently they use the callback function before getting rid of it.

@adamgrieger
Copy link
Contributor

adamgrieger commented Oct 21, 2018

I'm currently working on a TypeScript rewrite with backwards compatibility in mind (I'll see how far I get). Would it be a good compromise to keep callbacks but implement Promise support using the standard API available in ES6 and TypeScript? I feel like quite a few people still use this library in an ES5 environment, so requiring them to use a Promise polyfill and convert code might be a little overwhelming for some.

@JMPerez
Copy link
Owner Author

JMPerez commented Oct 22, 2018

Thanks for your input @adamgrieger! Promises are widely supported these days and they are easy to polyfill for those projects targeting browsers like IE 11 and older. I tend to prefer having one way of doing something in the library instead of having 2 and then keep supporting the magic that assumes callback or options depending on the type of the parameter passed.

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

No branches or pull requests

2 participants