question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Support for Observable (as opposed to Promise)

See original GitHub issue

Feature Description Axios is currently promise based library. It would be great that if it also support observable. Two great benefits of using observables:

  1. leveraging rxjs operator
  2. cancel http request through unsubscribe (as opposed to cancel token)

Existing Solutions I have implemented a library axios-observable(https://www.npmjs.com/package/axios-observable). It’s basically a thin wrapper around axios with almost the same API as axios. It also enables cancelling http request through unsubscribe - a more straightforward way than using cancel token.

Proposals I am thinking if we can incorporate axios-observable into axios to make observable officially supported. If you guys are very positive about this idea, I will be very happy to make an PR.

Happy to discuss.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
yasufcommented, Oct 25, 2019

Interesting idea and concept. To be completely honest, I don’t see axios implementing observables in the short run at least, your library seems pretty cool and I think the best way for us to move forward is with separate libraries to keep each one small and let developers decide which pattern to follow.

Open to other ideas, these are just my first impressions, I’ll let others share their opinions as well

1reaction
jasonsaaymancommented, May 28, 2020

HI,

Thanks for submitting this I don’t think that this is something that Axios will implement any time soon.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

When to use Promise over observable? - Stack Overflow
An observable does everything that a promise does and more. It can always be switched to a promise with toPromise() method in case...
Read more >
Angular Observable vs. Promise & How to Create Them
Something to remember is that Angular Promise is more passive compared to the Observable and cannot be cancelled once it is started. In...
Read more >
Promise vs Observable in Angular with (.subscribe, .then , .pipe).
A Promise is not lazy where as an Observable is Lazy. Let's prove this with an example. Consider this method getEmployeeByCode() in employee....
Read more >
Observables compared to other techniques - Angular
Observables are often compared to promises. Here are some key differences: Observables are declarative; computation does not start until subscription.
Read more >
JavaScript Promises vs. RxJS Observables - Auth0
The best thing about Promises is that they come built-in with JavaScript. That means we don't have to add anything to our package...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found