-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
HttpService should return promises #471
Comments
I totally agree with this +1 |
Sorry but I am going to have to reverse my position here. While the statements in the original issue post above are valid, changing the HttpService to return Promises pushes the problems of testing code that mixes Observables and Promises off to the developers using Nest. TL;DR keeping the method return values as Observables mean developers can mock the methods to return Observables using a test scheduler. |
Exactly 🙂 Moreover, Observable operators are more descriptive than just a chain of |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm submitting a...
Current behavior
All methods in the HttpService return Observables.
Expected behavior
All methods in the HttpService should return Promises.
Minimal reproduction of the problem with instructions
N/A
What is the motivation / use case for changing the behavior?
Promises are meant to be used when a single value/event is expected while Observables are meant to be used when a continuous stream of values/events are expected. Since HTTP calls always produce a single value, we should not wrap these as Observables. Additionally, Promises are not compatible with test schedulers making testing more difficult. See here.
Environment
The text was updated successfully, but these errors were encountered: