Home / Angular / What is the difference between Angular – Promise vs Observable

What is the difference between Angular – Promise vs Observable

  • promise:
    1. returns a single value
    2. not cancellable
    3. more readable code with try/catch and async/await
  • observable
    1. works with multiple values over time
    2. cancellable
    3. supports map, filter, reduce and similar operators
    4. use Reactive Extensions (RxJS)
    5. an array whose items arrive asynchronously over time

 

 

Often Observable is preferred over because Promiseit provides the features of Promise and more. With Observable it doesn’t matter if you want to handle 0, 1, or multiple events. You can utilize the same API in each case.

 

source: https://stackoverflow.com/questions/37364973/angular-promise-vs-observable

About Mohammad Fareed

Software Engineer @ Tekzenit.

Check Also

What’s new In Angular 5? What Is the Difference Between Angular 4 and Angular 5?

Angular, one of the best open-source JavaScript frameworks for web application development, recently upgraded with …

Leave a Reply

Your email address will not be published. Required fields are marked *