1

I know that in Angular everything revolves around observables but I don't really get why they are supposedly better than promises when it comes to the http services.

For websockets it makes sense cause the flow of data is continuous bidirectional but for calling RESTful services with AJAX behind the scenes I am not really sure what are the benefits, especially when to do just one shot call (e.g. GET) in the ngOnInit?

And since the http services is mostly for doing calls to web services and I guess primarily not for websockets, I don't really get the gist, it's not overkill?

https://angular.io/guide/comparing-observables

Natalie Perret
  • 8,013
  • 12
  • 66
  • 129
  • 1
    If you really want promise, you can use the https://www.learnrxjs.io/operators/utility/topromise.html, but observables can be cancelled in case of timeout, when promises cannot. – Leo Caseiro Jun 06 '18 at 00:20
  • @LeoCaseiro agreed, but the cancellation reason seems relatively a bit shallow, but got, in case of simple ajax calls, that was most likely the main reason for the Angular team. Was more interesting about the why, I know the differences between the two. – Natalie Perret Jun 08 '18 at 10:51

0 Answers0