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

Add a Comment

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