Explain the difference between Promise and Observable in Angular?

Technology CommunityCategory: AngularExplain the difference between Promise and Observable in Angular?
VietMX Staff asked 3 years ago

Promises:

  • return a single value
  • not cancellable
  • more readable code with try/catch and async/await

Observables:

  • work with multiple values over time
  • cancellable
  • support map, filter, reduce and similar operators
  • use Reactive Extensions (RxJS)
  • an array whose items arrive asynchronously over time